0 LIKES LikeUnLike
I'm writing the second program for my c language class and I'm hung up trying to get my simple program to loop. I am attempting to use a while loop to ask the user if they would like to use the program again. Here is my main function:/* beginning of function main */int main (void){/* variable prototypes for function main */ int grade = 0; char cgoAgain = 'y'; /* beginning of while loop for cgoAgain */ while(cgoAgain == 'y' || cgoAgain == 'Y') { /* calls function getGrade to acquire user input */ grade = getGrade(); /* sends acquired input to function calculateGrade */ calculateGrade(grade); printf("\nWould you like to calculate another grade (y/n)?"); scanf("%c%*c",&cgoAgain); } /* end of while cgoAgain loop */ return 0;}in my scanf string I have to use %c%*c to hold my variable for cgoAgain but it never happens. The program works if I use %s instead but my instructor said we haven't gone over that yet and I can't use it. He also said there is an obvious error I am overlooking but won't give me any specific information. Please Help!
Tags:
Report (0) (0) | earlier
Latest activity: earlier. This question has 5 answers.