大家帮忙看一下 第21行为啥不加空格会错误?vc++6.0下运行 。。
# include <stdio.h># include <ctype.h>
int main(void)
{
char answer = 'N';
double total = 0.0;
double value = 0.0;
unsigned int count = 0;
printf("This program calculates the average of any number of value.\n");
for(;;)
{
printf("\nEnter a value: ");
scanf("%lf", &value);
total = total + value;
++count;
printf("Do you want to enter another value? ( Y or N):");
scanf(" %c", &answer); // 为啥 %c前面要加空格?
if(tolower(answer) == 'n')
break;
}
printf("\nThe average is %.2lf\n", total/count);
return 0;
}