Monday, July 2, 2018

c - While Loop doesn't stop executing

The "while" in my code doesn't stop running even when I type " ^Z "
it's supposed to stop since the EOF exists.
Any idea why?


 #define NUM_OF_GRADES 10
int maxInArray();
int main()
{ char ch1;
int grades[NUM_OF_GRADES];
int grade;
printf("Please enter a character:");
printf("\n");
scanf("%c",&ch1);
printf("Please enter grades:");
printf("\n");
while (scanf("%d",&grade)!=EOF)
{
grades[grade-1]++;
}
return 0;
}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...