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 1 0 3 Correct
- B 3 1 0
- C 1 garbage 3
- D Compilation error
Correct Answer: Option A
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!