'QTextStream::readLine() after >> with stdin
I'm trying to read text with spaces from keyboard using object of QTextStream connected with stdin:
QTextStream cin(stdin, QIODevice::ReadOnly);
When I use >> it reads only till space.
QString str;
cin >> str;
readLine() reads until end of the line
str = cin.readLine()
But when readLine() used after >> it just skips and doesn't do second read. I suppose it because after >> it remains in the same line which is now empty.
cin >> str;
str = cin.readLine()
How can I force readLine() to perform second read? I can use empty readLine() to go to the next line, but maybe the are another solution?.
cin >> str;
cin.readLine()
str = cin.readLine()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
