Search code examples
c++xcode4user-input

XCode 4 console won't take user input


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?


Solution

  • 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.

    • Unshifted must be the Return
    • Shifted must be the Enter.