+ 2

What does the code in description below means?

n=(struct node*)malloc(sizeof(struct node));

26th Nov 2017, 2:00 PM
Akash papnai
Akash papnai - avatar
2 Answers
+ 8
It means, you request system to allocate some memory (using malloc) the size of the allocated memory is just about the number of bytes it is needed to create a node structure. Then you cast the address of memory block allocated to a pointer of a node structure which you then assign to a variable named n. Hth, cmiiw
26th Nov 2017, 2:14 PM
Ipang
0
It's the same as: n = new struct node;
26th Nov 2017, 8:45 PM
Timon Paßlick