In XCode 4, when I run something like this:
string input;
cout << "Enter command" << endl;
getline(cin, input);
cout << "You entered: " << input << endl;
I see my "Enter command" prompt in the console. But when I place my mouse cursor below it and start typing the cursor doesn't move, and my keystrokes don't show up. It basically behaves like a read-only text box. What am I doing wrong? How can I interact with my program as if it were running in the terminal?
Are you pressing Return or Enter at the end of your input line?
For some keyboard the enter and return are on the same button, but if you press "shift" key, while pushing the enter/return button scanf will work.
From the site “Xcode Tools Tips”:
When debugging a command line program with Xcode, one problem you may have is figuring out where to input data and read the program's output. If you open the debugging console window by clicking the Console button, you will be able to see your program's output, but you will get an error message any time you try to enter input in the console window. Where do you enter the input your program needs?
The answer is Xcode's standard I/O log. The standard I/O log works similarly to Xcode's run log when you run your program in Xcode without the debugger. Choose Debug > Standard I/O Log to open the log window. Now when you debug your program, you will see its output in the standard I/O log, and you will be able to input any data your program needs to run.
By the way, all I did to find that quote was to highlight your question in the browser, and select “Search” in the browser’s right click menu. It was the fourth hit in Google’s list.
I think, it’s pretty much very often a good idea to google before asking!
Cheers & hth.,
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