Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all,
Please, help me with this strange problem. Whenever I invoke more than one getline(cin, string1) function in my codes, some of them are skipped at run-time i.e. the user is not prompted for input and the program simply jumps to another line e.g.in
getline (cin, string1);
getline (cin, string2);
The user is never prompted for string1. The user is only prompted for string2.
Posted

1 solution

You may try to call cin.ignore(); just before getline(cin, string1); (if you have a spurious newline in the input buffer).
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900