C | Structure & Union | Question 5
#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; } |
chevron_right
filter_none
(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
Recommended Posts:
- C | Structure & Union | Question 10
- C | Structure & Union | Question 9
- C | Structure & Union | Question 1
- C | Structure & Union | Question 2
- C | Structure & Union | Question 4
- C | Structure & Union | Question 8
- C | Structure & Union | Question 7
- C | Structure & Union | Question 6
- C | Structure & Union | Question 10
- Anonymous Union and Structure in C
- Difference between Structure and Union in C
- Output of C++ programs | Set 41 (Structure and Union)
- Output of C programs | Set 44 (Structure & Union)
- Union in C
- C | Loops & Control Structure | Question 4



