Why do I need "clear" the I/O input with a dummy getline() call before I use getline() in terminal I/O?
So I’m writing a C++ program, see, and it uses cin>> a lot. For some sub-parts of the program, however, I need to use getline(cin,whatIWant); to access data values. No matter what I do, the FIRST call to getline after I have already used a cin>> above that does absolutely nothing – C++ skips it as if there is data already in the terminal that it just reads. I have determined it is reading absolutely nothing with a test dummy variable. Is there any more elegant solution than:
getline(cin, dummy); // OK, now I can get real values now
Thanks for your help!
This question is in the General Section. Responses must be helpful and on-topic.