PDA

View Full Version : Why doesn't QTextStream wait for input?



fyodor
20th December 2011, 00:12
In this little program why doesn't in wait for input?

#include <QtCore>

int main(int argc, char *argv[])
{
QTextStream in(stdin, QIODevice::ReadOnly);
QTextStream out(stdout, QIODevice::WriteOnly);

QString str;
out << "Enter something: ";
in << str;
out << "hello " << str << "\n";

return 0;
}
When i execute this i get

Enter something: hello
Press <RETURN> to close this window...
So what is going on that i don't understand?

ChrisW67
20th December 2011, 06:08
You are using operator<<() when you should be using operator>>() at line 10