Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

C | Structure & Union | Question 5

  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021
Geek Week




#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; 
}

(A) Compiler Error
(B) 10
(C) Runtime Error
(D) Garbage Value


Answer: (A)

Explanation: A structure cannot contain a member of its own type because if this is allowed then it becomes impossible for compiler to know size of such struct. Although a pointer of same type can be a member because pointers of all types are of same size and compiler can calculate size of struct

Quiz of this Question

Take a step-up from those “Hello World” programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.
My Personal Notes arrow_drop_up
Recommended Articles
Page :