Question 5
Back to Exercise
The program below has a bug. Which statement correctly describes it?
#include <stdio.h>
int main(void) {
register int n = 10;
int *p = &n;
printf("%d\n", *p);
return 0;
}
- A register variables cannot be initialised
- B The address of a register variable cannot be taken Correct
- C p must be a register pointer
- D There is no bug
Correct Answer: Option B
Even though compilers ignore the register hint for code generation, the language still forbids & on such a variable. Drop register – it brings no speed today.
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!