开发平台(Platform):
Programiz C Online Compiler
问题(Question):
如下程式码,boolean variable flag出while循环就消失了,有人知道原因吗?
喂入的资料(Input):
2 (随便输入的数字)
预期的正确结果(Expected Output):
2
The internal boolean variable is 1
The external boolean variable is 1
错误结果(Wrong Output):
2
The internal boolean variable is 1
程式码(Code):(请善用置底文网页, 记得排版,禁止使用图档)
#include <stdio.h>
#include <stdbool.h>
int main() {
bool flag = true;
int digit;
while (scanf("%d", &digit) != EOF) {
printf("The internal boolean variable is %d\n", flag);
}
printf("The external boolean variable is %d\n", flag);
return 0;
}
先谢谢了!