The output will most probably explain it
[Enter Name: Somebody
Enter Grade: A
Enter Marks: 100
Do you want to enter more? : Y
Enter Name:
Enter Grade: A]
Basically When the second time I add information, it doesn't take the name. This problem comes for me in nearly every program, but I don't know why. Please help me out.
You could also try putting a cin.ignore() before the line that cause problem. I remember it solving those kind of problem when I had to do simple interfaces for school assignements.
The ignore() discards anything. The std::ws discards only whitespace.
When the user may or may not add whitespace (like newline) between "data fields", the ws is more convenient.
When there is always an offending newline before getline() "data field" and the field has prefix whitespace that cannot be skipped, the ignore() is more convenient.
Thank you very much, you solved a problem which was very annoying for me!
Since newline is the problem, I fixed it by adding cin.get(some_char_variable) to remove the newline.