Back, again ^^;
So basically, title. How do I make it that there is like a 'break' in the text. I'm aware of the following:
cin.ignore();
and my problem with it is that it only sometimes works. I'm confused, I tested it out on atom.io and repl.it and had the same issue, is it just me? Is there something I'm doing wrong?
Your code will not work everytime. If cin was not called by the overloaded operator >> (or another way), then this function causes the user to have to press the enter key twice.
This is because you have cin.ignore() and cin.get(). You should not use cin.ignore() when it was not used. Which I do not know of a way to check.
Your code will not work everytime. If cin was not called by the overloaded operator >> (or another way), then this function causes the user to have to press the enter key twice.
This is because you have cin.ignore() and cin.get(). You should not use cin.ignore() when it was not used. Which I do not know of a way to check.
This should work for most cases. Also please be careful when using cin.ignore(), since it may pause the program unexpectedly if used incorrectly.
Thanks for providing an answer that was worse than my first implementation.
What if cin isn't good() ? It prematurely terminates.
What if the formatted input is used? It prematurely terminates.
cin.ignore() is often used with cin.clear() to handle stream errors.
However, cin.ignore() can be also used to remove trailing newline characters before using std::cin.getline().