Question 8
Back to Exercise
Compiled as C17, why does this program fail?
#include <stdio.h>
int main(void) {
bool ready = true;
printf("%d\n", ready);
return 0;
}
- A bool must be capitalised
- B printf cannot print a bool
- C There is no bug
- D Before C23, bool and true are macros from <stdbool.h>; without that header they are unknown Correct
Correct Answer: Option D
In C99–C17 the built-in type is _Bool; bool, true and false come from #include <stdbool.h>. In C23 they are keywords and this program compiles as it is.
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!