#include <stdio.h>
struct st
{
int x;
struct st next;
};
int main()
{
struct st temp;
temp.x = 10;
temp.next = temp;
printf("%d", temp.next.x);
return 0;
}
Answer: A
Correct answer: Compiler Error
A structure cannot contain an instance of itself - the type would be infinitely large, since each copy would contain another. The compiler rejects struct st next;. What is allowed is a pointer to the same type, struct st *next;, since a pointer has a fixed size; that is how linked lists are built.
Please log in or register to report this question.