I've spent probably 4 solid hours searching this forum, on the faq and on google looking for buffer clearing solutions.
It amazes me that a seemingly routine task does not yet have a 'one size fits all' function in this language. Maybe that's wishfull thinking, but all I've seen in my research are 10 different ways to get the job done, more or less, with each method having a potentially unpleasant downside, and much disagreement on the best methods.
My first question to you pros is, is there a logical reason why c++ does not have a "clear_the_damn_buffer_already()" function yet, similar to cout.flush? Is it my job as a nube to just, "learn it and live with it"?
Anyway, my situation seems like it might be a tad different than the examples I've seen, and the language and librarys are still very confusing right now.
I'm using getch() for a user menu selection. First, is this function the same as getchar()? I believe that I read that getch() takes unbuffered input, but it's obviously buffering it 'cause it's dumping it into my next input stream.
Here's my code basics. For user option 1 (getch()), the view record function is called and reads the structure from disk with getline() and outputs to screen. No buffer problem here.
Next, for user option 2 (getch()), the create record funtion is called where I take user input via getline(). The getch() character is displayed on the first input line here, so I have to backspace.
Now, I've tried cin.ignore(1) before the first getline but that just stalls the program, and takes infinite input until I hit return. I haven't tried any other methods yet because I want to understand what's going on first.