+ 1
(struct node *)malloc (sizeof(struct node)) what is the use of "*"in it?
2 Answers
+ 9
Keerthana The (struct node*) is a cast, which is a way to tell the compiler that you want to treat the value returned by malloc as a pointer to a structure.
+ 2
malloc returns pointer of newly allocated memory.. and you are typecasting that memory to pointer only... that's why it is * inside type conversion...
for more info:
http://www.cplusplus.com/reference/cstdlib/malloc/