PDA

View Full Version : problem with reading input from user



ketan007
5th December 2009, 07:45
hi guys....
I have a problem while i m try reading some input from the console user....check out the code below:
#include <QTextStream>
#Include <QString>
int main()
{
1 using namespace std;
2 QTextStream cin(stdin);
3 QTextStream cout(stdout);
4
5 QString str;
6 cout<< "enter text:"<<endl;
7 str = cin.readLine();
8 cout<<"the length of text is: \n"<<str.length()<<endl;
9 return 0;
}
when i execute this prog it starts taking input from me endlessly...i mean d control wont go the 8th line as shown in code to calculate d length....
Any help welcome...
thnx...

caduel
5th December 2009, 11:51
remove the "using namespace std;" line; it is not needed.
anyway it is confusing as then it is "unclear" if cout is yours or std::cout.

HTH