XCode 4 console won't take user input

前端 未结 3 1394
灰色年华
灰色年华 2021-01-03 06:30

In XCode 4, when I run something like this:

string input;
cout << \"Enter command\" << endl;
getline(cin, input);
cout << \"You entered: \"         


        
3条回答
  •  旧巷少年郎
    2021-01-03 07:02

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

提交回复
热议问题