I'm developping a very simple app on my Mac using QtCreator.
It's a console application and I want the user to enter its name, and then I display his name. Here is the code :
#include <iostream> int main(int ArgC, char* ArgV[]) { char Name[1000]; std::cout << "Type your name : "; std::cin >> Name; std::cout << "Hello " << Name << "\n"; return 0; }
When running this app with QtCreator, the string "Type your name :" is displayed in the 'Application Output' tab. But if I type some text and press the enter key, nothing is happening.
What's wrong ?
I found a solution. With Qt Creator 1.3.0 (on Mac OS X), here is what I had to do :
/usr/x11/bin/xterm -e
.Now, everything is working fine !
Go to Project -> Run settings, and make sure "Run in Terminal" is checked.
BTW:
std::cin >> Name;
is probably not what you want. It will read just a single token (typically only the first name). You should have a look at getline, or the string version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With