Getline problem

can someone help me?
i just make my code with linked list but there is a problem
when i compile the code getline(cin,position -> firstname) not worked and jump to the next line getline for lastname.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  string temp;
                    cout << "____________________________[Student Bearbeiten]______________________________\n" << endl;
                    cout << "Firstname               ";
                    temp = position->firstname;
                    getline(cin,position->firstname);
                    if(position->firstname == "")
                        position->firstname = temp;
                    cout << "Lastame                 ";
                    temp = position ->lastname;
                    getline(cin,position->lastname);
                        if(position->lastname == "")
                        position->lastname = temp;
                    cout << "Sex                     ";
                    temp = position ->sex ;
                    getline(cin,position->sex);
                        if(position->sex == "")
                        position->sex = temp;
                    cout << "Matriculation Number    ";
                        cin >> position->matriculation_number;

                    cout << "Final Mark              ";
                        cin >> position -> final_mark;
Last edited on
closed account (48T7M4Gy)
Add a line cin.ignore(); before getline as a start to solving your problem
Last edited on
Topic archived. No new replies allowed.