I'm writing a CLI
application in Windows
that accepts a string
as an input. I assume the end of the input is when user presses Ctrl+Z (that imitates EOF
).
When I enter "qwe" and press Ctrl+Z the getline
instead of just assigning the "qwe" to tmp
asks me to input one more line for some reason. However, the resulting value in tmp
is still "qwe" ignoring the extra line. The code I use is the following:
string tmp;
getline(cin, tmp);
UPD:
As it was said in C++ Issue with cin and CTRL + Z, it's just the usual Windows behavior, where the Ctrl+Z symbol must
be at the beginning of the line.
To get the multiline input you should use read by characters until you meet '\n' || EOF
.