I am working on a basic linked list program and i seem to be having problems with the getline() function.

I try to input data in to my struct:

cout<<"\n\nPlease enter the name of the student: ";
    getline(cin, temp->name);
    cout<<"Please enter "<<temp->name<<"'s class: ";
    cout<<"Please enter "<<temp->name<<"'s GPA: ";

but when i do this it ignores the first getline statement and continues to the next ourputr line and then i can enter the students class. My question is why does it jump over the getline?

If you need more of the code i can post it all. Its only about 100 lines so far.

This is very often an issue where you have an excess newline character in the input stream from an earlier cin statement. The cin statemnent doesn't consume that newline. getline sees the newline, takes it, and doesn't pause for input. You want to flush the input stream so that any excess characters are removed before the getline statement. That way the program will pause when it sees getline.


That works just fine thanks mate!