Question 1
Back to Exercise
What is the output of the following C program on a 64-bit system?
#include <stdio.h>
struct point {
int x, y, z;
};
int main(void) {
struct point p = {.z = 3, .x = 1};
printf("%d %d %d\n", p.x, p.y, p.z);
return 0;
}
- A 3 1 0
- B 1 garbage 3
- C Compilation error
- D 1 0 3 Correct
Correct Answer: Option D
Designated initializers can come in any order. Members that are not named – here y – are set to 0, as with any initializer.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!