Question 2
Back to Exercise
The program below has a bug. Which statement correctly describes it?
#include <stdio.h>
typedef static unsigned int Counter;
int main(void) {
Counter c = 3;
printf("%u\n", c);
return 0;
}
- A unsigned int cannot be aliased
- B typedef and static are both storage-class specifiers, and only one is allowed per declaration Correct
- C Counter must be lowercase
- D There is no bug
Correct Answer: Option B
A typedef names a type; storage duration belongs to variables. Declare the alias normally and use static Counter c; on the variable.
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!