XCode 4 console won't take user input

11,581

Solution 1

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.

Solution 2

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

Solution 3

In the bottom pane of the debug window[which shows variables and their values], there is a search toolbar and a 3 option box in the upper right hand corner. Click on the middle of the three options which will display the main debug output to the right of the variable pane. The top pane is only for output. The right pane can be used to enter input.

I hope this helps. Sorry that the note is late.

Share:
11,581
Imran
Author by

Imran

imran.hendley (at) protonmail

Updated on July 17, 2022

Comments

  • Imran
    Imran almost 2 years

    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?

  • Imran
    Imran almost 13 years
    Hi, thank you. I think this is specific to older versions of XCode. I can find no such option in XCode 4, and I found a post that said the console window is supposed to handle input. I did spend a long time on google before posting my question, but I wasn't able to find anything useful.
  • Litherum
    Litherum about 12 years
    This option has been removed in XCode 4 :-(
  • Biscuitz
    Biscuitz over 11 years
    after i "highlight this question in the browser, and select “Search” in the browser’s right click menu" i come to this question on Google
  • binary_falcon
    binary_falcon over 11 years
    This is specific to XCode 4.0+
  • Ad N
    Ad N over 9 years
    In XCode 5.x, I need to push shift+enter key to generate the Enter key code. Thank you for the information.
  • hbk
    hbk over 9 years
    Shifted must be the Enter