求助 怎么退出循环
代码如下,输入什么能退出循环呢? 我用的VC++ 输入 -1 , 0 都没能退出#include <stdio.h>
void main ()
{
int grade;
int aCount=0,bCount=0, cCount=0, dCount=0, fCount=0;
printf ("Enter the letter grades.\n");
printf ("Enter the EOF character to end input.\n");
while ( (grade=getchar() )!=EOF)
{
switch (grade)
{
case 'A': case 'a':
++aCount;
break;
case 'B' : case 'b':
++bCount;
break;
case 'C' : case 'c' :
++cCount;
break;
case 'D' : case 'd' :
++dCount;
break;
case 'F' :case 'f' :
++fCount;
break;
case '\n' :case ' ':
break;
default :
printf ("Incorrect letter grade entered.");
printf ("Enter a ew grade .\n");
break;
}
}
printf ("\nTotals for each letter grade are: \n");
printf ("A :%d\n", aCount);
printf ("B :%d\n", bCount);
printf ("C :%d\n", cCount);
printf ("D :%d\n", dCount);
printf ("F :%d\n", fCount);
return;
}