Omkar
Planet
Lucas
Can anyone recommend c++ books?
Soubarna
How do I interpret the arrow operator (->) in C/C++ when three or more operands are involved? For example, if a, b and c are the operands, how do you interpret a->b->c?
Pavel
If it was a function call
a->foo()->bar()
Then it could be that foo() returns a pointer to something, sometimes it can return pointer to a again, it's called chaining (if I'm not mistaken)
Pavel
Code like this
std::cout << 1 << 2;
implemented using chaining basically under the hood
Soubarna
Thanks a lot @gameraccoon
Void
#include <stdio.h>
int main()
{
long int s,x=1;
int n,i;
s=0;
for(n=1;n<20;n++)
{
for(i=n;i>0;i--)
{
x=x*i;
}
s=s+x;
x=1;
}
printf("%d",s);
return 0;
}
Void
Guys why do I get a negative result
Void
Void
#include <stdio.h>
int main()
{
int i,j;
long int sum,n;
sum=0;
for(i=1;i<=20;i++)
{
n=1;
for(j=1;j<=i;j++)
{
n=n*j;
}
sum=sum+n;
}
printf("%d",sum);
return 0;
}
Void
I wrote almost the same program and this time it worked.But what's the difference?
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
I guys! If I have a struct like this:
struct node_t{
struct node_t *next;
char *string;
}
Which represents a node in a list.
And a node
struct node_t *new;
when I need to delete new, I'll have to save the current location this way:
struct node_t *to_free= new; struct node_t *to_free;
// Stuff
free(to_free);
ok, but is it right? In fact, we do have two more pointers inside the node: the pointer "next" to the next node in the list, and the char *. Do I need to free them too?
Shobi
finclude <type.h> /• loads file with predicate isdigit */ int lookahead;
main()
lookahead = getchar ();
exprl):
putchar ('\n'); /* adds trailing newline character */
expr ()
term();
while (1)
if (lookahead == '+') {
match('+'); term(); putchar ('+');
else if (lookahead == '-*) (
match ('-'); term(); putchar ('-');
)
else break:
term ( )
if (isdigit (lookahead)) 1 putchar (lookahead); natch (lookahead);
else error();
match(t)
int t;
if (lookahead *= t)
lookahead = getchar ();
else error ();
)
error ()
printf ("syntax error\n"); /* print error nessage exit (1);
then halt
Shobi
Anonymous
How can I convert my C code to an apk from Android (i have made an program and want to conver it in an apk so that if someone will open that apk that program shows up)
Because i need to share it as a presentation
Khadija
Hi hope you are doing well
Please i need help , anyone have a free course about complexity and big notation ? , or any sources that help me ✨?
Thank you so much …
Anton
Void
j. c o l e
hey
j. c o l e
who can help with discrete math?
You know me
Void
Boom
https://hastebin.com/okotoyujez.cpp
Boom
https://hastebin.com/okotoyujez.cpp
this is a program for linked list , and i have only written it till add function, and I am getting Segmentation error in VS code and Dev C++ but the program runs fine in online compiler, Please help me to know why is this happening!
\Device\NUL
Boom
\Device\NUL
\Device\NUL
It's only free the memory allocated for struct, not allocated memory for the member
Boom
Gain
i want to find all the indexes of a element present in a array..
eg {1,2,3,2}
if want to find index of 2 .. i should get {1,3}
using find only gives me index 1
Gain
Pavel
thx
Also SO answer with code examples
https://stackoverflow.com/questions/25846235/finding-the-indexes-of-all-occurrences-of-an-element-in-a-vector
Richard Luo 🐱
https://www.godbolt.org/z/4zPxzWz8W how to make this work?
Richard Luo 🐱
I dont understand why compiler think Type is not deducible
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Anonymous
https://www.godbolt.org/z/4zPxzWz8W how to make this work?
Well think about it. The compiler says it is a non deducible context because given information about B, it is not possible for the compiler to deduce which A instantiation it is a part of.
For ex I could have a specialization of A like this:
class MyUDF{...};
template<>
class A<int>{
public:
using B = MyUDF;
};
So suppose hash were called for MyUDF, how is the compiler supposed to deduce that Type is int based on that?
Richard Luo 🐱
Anonymous
Anonymous
For any specialization of A, B can be hash using this hasher
That is not possible at all based on what I just said.
template<>
class A<Alpha>{
public:
using B = MyUDF;
};
template<>
class A<Beta>{
public:
using B = MyUDF;
};
What would the compiler do?
Again, am asking why you want to do this? Why should the parent class's template parameter control the hash template instantiation for a nested class? That just doesn't make sense at all forgetting that the compiler won't allow you to do it.
Richard Luo 🐱
Richard Luo 🐱
Boom
https://hastebin.com/okotoyujez.cpp
Boom
https://hastebin.com/okotoyujez.cpp
this is a program for linked list , and i have only written it till add function, and I am getting Segmentation error in VS code and Dev C++ but the program runs fine in online compiler, Please help me to know why is this happening!
Resul
Hi,
How to Append a Char to a Char Pointer?
char self = 'k';
char *word;
word = (char*) malloc(12*sizeof(char));
Resul
Talula
I changed post
The simplest way to do that is #include <stdio.h>
int main()
{
char word[10];
word[0] = 'k';
word[1] = 'o';
word[2] = '\0';
printf("%s\r\n",word);
return 0;
}
Resul
Talula
I know that, I just want for Pointer
#include <stdio.h>
int main()
{
char word[10];
word[0] = 'k';
word[1] = 'o';
word[2] = '\0';
char *wordp = word;
wordp[2] = 'v';
wordp[3] = '\0';
printf("%s\r\n",wordp);
return 0;
}
Void
Can i set p=a[3][1] ? (p is a pointer)
Talula
Void
It shows [Error] invalid conversion from 'int' to 'int*' [-fpermissive]🥲
Anurag
I am new to c++, tried making a Class Array.. with sort, search and display methods.
When i call method with reference to object it prints garbage values of array.
I don't know much about how classes work in c++.
https://pastebin.com/Hbdi5BHC
Daulet
Anurag
Daulet
Someone help pls
int A[size]; line is wrong.
Correct: int* A = new int[size];
Anonymous
class sample{
int var;
static int count;
public:
sample(int var):var(var){ // What exactly does this line do? could you please explain?
cout<<"Count = "<<count<<endl;
count++;
}
};
\Device\NUL
Void
int
Daulet
Daulet
int
But you need to use int**
Void
ohh yes int*
\Device\NUL
int
*(*(a + 3 * sizeof(int) + sizeof(int))
Void