Q. Consider the following definition in c programming language
struct node
{
int data;
struct node * next;
}
typedef struct node NODE;
NODE *ptr;
Which of the following c code is used to create new node?
-
(A)
ptr=(node*)malloc(sizeof(node));
-
(B)
ptr=(node*)malloc(node);
-
(C)
ptr=(node*)malloc(sizeof(node*));
-
(D)
ptr=(node)malloc(sizeof(node));
β
Correct Answer: (A)
ptr=(node*)malloc(sizeof(node));