Question 2
Back to Exercise
What is the output of the following C program on a 64-bit system?
#include <stdio.h>
#define STR char *
typedef char *Str;
int main(void) {
STR a, b;
Str c, d;
printf("%zu %zu %zu %zu\n", sizeof a, sizeof b, sizeof c, sizeof d);
return 0;
}
- A 8 1 8 8 Correct
- B 8 8 8 8
- C 1 1 8 8
- D 8 1 8 1
Correct Answer: Option A
The macro expands to char * a, b;, so b is a single char (1 byte). The typedef makes both c and d pointers (8 bytes each).
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!