I am making a program for some friends and myself that calculates grades with the weighted percentage and what grades need to me made on the final to pass the class with a specified grade.
The for loop in question is this,
for(;;)
{
scanf("%f", &s->grade);
if(s->grade == 'x')
{
break;
}else{
grade += s->grade;
}
}
how can I make this exit through the use of a letter rather than a number?
If you need any more code feel free to ask.
scanfreturns the number of arguments assigned. Check that!scanfdoes omit all preceding whitespace (unless%cis used), then if first non-whitespace character is non-digit (or possibly+,-sign), then it "fails" and does not read more (in fact such "unwanted" character is given back tostdinstream and no futher characters are processed.