[linked list] What does this line mean ptr = (struct node)malloc(size of(struct node)) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[linked list] What does this line mean ptr = (struct node)malloc(size of(struct node))

i also wanna know what does malloc do and how do we get to know where is the first node ?

3rd Nov 2016, 10:45 AM
Infinity
Infinity - avatar
1 Answer
- 1
you have not write right syntax ptr = (struct node*)malloc(sizeof(struct node)); It is use to create a memory block in Ram. Mainly use in Data structure. Always use pointer variable to create a memory block because a pointer can contain adress of memory block. It create struct node size memory block. for more comment
3rd Nov 2016, 10:54 AM
Aditya kumar pandey
Aditya kumar pandey - avatar