ProgrammingHard
struct S { int a; char c; } arr[2] = {{1}}; printf("%d", arr[1].a); What is printed?
- A. 1
- B. garbage
- C. 0
- D. 2
Correct answer: C. 0
Members left out of an aggregate initialiser are zero, so arr[1].a is 0.
More C Programming questions
- int a[5] = {[2] = 7, 9}; printf("%d", a[3]); What is printed?
- char s = "hi"; s++; printf("%s", s); What is printed?
- int x = 1; { int x = 2; printf("%d", x); } printf("%d", x); What is printed?
- printf("%d", (int)'A' + 'x01'); What is printed?
- for (char c = 'z'; c > 'w'; c--) putchar(c); What is printed?
- printf("%d", sizeof(void ) == sizeof(int )); What is printed?