Basically, my only problem with my code is that when it asks for the student name, and I type anything with spaces (ex. Angelina Jolie, Brad Pitt), the program goes wrong. But if I type in only one word with NO spaces at all (ex. Brad, Pitt, Angelina, Jolie), my program works TOTALLY fine. :(
Hello! Thanks for your reply :) It works the first time around... cause my code loops ten times, so in the first time you type two or more words in the "name of student", it works. Here's a sample of the output:
Enter the name of the student: Andy Miller
Enter Quiz 1: 10
Enter Quiz 2: 10
Enter Quiz 3: 10
Enter Quiz 4: 10
Enter Quiz 5: 10
The student's average is: 10.000000
That's the result and it works, but once it loops back again (2nd loop) to the "enter of the name of student", this appears:
Enter name of student: Enter Quiz 1:
I can't enter the student name anymore, which is NOT my desired result. :(
Yes: the fgets also reads the trailing '\n' char, that you have to eliminate by hand. Otherwise it remains in the buffer and spoils your next attempt to read.
Simply write a function that processes a string and removes the trailing '\n'. Then everything should work just fine.