Question 9
Back to Exercise
What is the output of the following C program on a 64-bit system?
#include <stdio.h>
typedef int Transform(int);
static int negate(int x) { return -x; }
int main(void) {
Transform *t = negate;
printf("%d %zu\n", t(7), sizeof(Transform *));
return 0;
}
- A -7 8 Correct
- B -7 4
- C 7 8
- D Compilation error
Correct Answer: Option A
Transform names a function type, so Transform * is a pointer to such a function (8 bytes). This style keeps the * visible at the point of use, which some codebases prefer.
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!