C PRIMER PLUS 英文版上册 p204
#include <stdio.h>
int main(){
int num;
int sum = 0;
_Bool input_is_good;
printf("Enter a number to be summed up: \n");
input_is_good = scanf("%d", &num);
while(input_is_good){
sum += num;
printf("Enter a number to be summed up( q to quit): \n");
input_is_good = scanf("%d", &num);
}
printf("Those integers summed to %d\n",sum);
return 0;
}
error : ‘_Bool’ was not declared in this scope
没找到原因,只好引入布尔类型的头文件,同时把_Bool替换了
…
…
…
…
#include <stdio.h>
#include <stdbool.h>
int main(){
int num;
int sum = 0;
bool input_is_good;
printf("Enter a number to be summed up: \n");
input_is_good = scanf("%d", &num);
while(input_is_good){
sum += num;
printf("Enter a number to be summed up( q to quit): \n");
input_is_good = scanf("%d", &num);
}
printf("Those integers summed to %d\n",sum);
return 0;
}