That is programmer error - the programmer should always account for the extra newline after inputting values with the formatted extraction operator. |
More like a
design error: you are forcing programmer to study implementation details of particular function:
What is it doing: Waiting until user presses enter.
How is it done: Function skips all symbols up to first encountered newline,
so it will not work if there is already an unextracted newline symbol in input stream and programmer should account to that....
In opposite standard
getline() function:
What: Stores characters from
input stream in
string until it encounters
delimeter which is extracted, but not stored. Default delimeter is newline character.
How: I don't care.
You could either rename function into something like "readNewline()", fix this behavior or tell that it is "not a bug, it's feature" by documenting it. I think this is how some strange requirements are getting into normative documents in all fields around all the world...
cyberdude
Standard console doesn't clears screen after each program run. And there is good reasons for that. I you still want it, you were provided by
L B with link to article with several alternative ways to do this. The simpliest is to just output a bunch of newlines.