能不能换一个声明,为什么?
程序代码:
#include<stdio.h> int main () { long num; long sum=0L; int status; printf("Please enter an integer to be summed."); printf("(q to quit):"); status = scanf("%ld",&num); while (status == 1) { sum = sum +num; printf ("Please enter next integer (q to quit):"); status = scanf("%ld",&num); } printf("Those integers sum to %ld.\n",sum); return 0; }
程序代码:
#include<stdio.h> int main () { long num; long sum=0L; _Bool input_is_good; printf("Please enter an integer to be summed."); printf("(q to quit):"); input_is_good = (scanf("%ld",&num)==1); while (input_is_good) { sum = sum +num; printf ("Please enter next integer (q to quit):"); input_is_good = (scanf("%ld",&num)==1); } printf("Those integers sum to %ld.\n",sum); return 0; }
假设两个程序都可以运行,那能不能把_Bool换成int,为什么不行,不都是1或0吗