Xcode:调试时输入用户输入

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1780600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:57:59  来源:igfitidea点击:

Xcode: entering user input when debugging

xcodestringdebugginginput

提问by nightfire

int main()
{
    cout << "Buy or sell (b/s): " << endl;
    string buy_sell;
    cin >> buy_sell;
    .....
}

When i try to step through this in Xcode, it stops at the cin >> buy_sell line, because it's waiting for the user input. How do I enter the value in the debugger? I'm using Xcode 3.2.1.

当我尝试在 Xcode 中逐步执行此操作时,它停在 cin >> buy_sell 行,因为它正在等待用户输入。如何在调试器中输入值?我正在使用 Xcode 3.2.1。

(I know I could just comment out the cin lines and define the variable in the code for debugging purposes, but that would be very tedious, and I feel like there should be an easy way to enter input that I just don't know about.)

(我知道我可以注释掉 cin 行并在代码中定义变量以用于调试目的,但这会非常乏味,而且我觉得应该有一种简单的方法来输入我不知道的输入.)

采纳答案by Oz.

Are you using the XCode console? You can access it under the "Run" menu, just below the Debugger. The shortcut is command-shift-R. From there you can interact with the application exactly like a terminal, but from inside of XCode itself.

你在使用 XCode 控制台吗?您可以在调试器正下方的“运行”菜单下访问它。捷径是command-shift-R。从那里你可以像终端一样与应用程序交互,但从 XCode 本身内部。

回答by Matthew Read

In Xcode 8, the shortcut is +Shift+C. It seems to be shared with the Output window, by default at the bottom-right.

在 Xcode 8 中,快捷方式是+ Shift+ C。它似乎与输出窗口共享,默认情况下位于右下角。