Netbeans IDE for C++ 如何指定命令行参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9672072/
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
Netbeans IDE for C++ how to specify command line arguments
提问by ManInMoon
How do I specify command line arguments for a netbeans C++ project?
如何为 netbeans C++ 项目指定命令行参数?
There does not seem to be a suitable place on debug tab.
调试选项卡上似乎没有合适的位置。
回答by fabregas88
To specify command line arguments for a C++ project in netbeans go to:
要在 netbeans 中为 C++ 项目指定命令行参数,请转到:
Project properties
=> Run
=> Run Command
Project properties
=> Run
=>Run Command
The default is:
默认为:
"${OUTPUT_PATH}"
"${OUTPUT_PATH}"
Change that to:
将其更改为:
"${OUTPUT_PATH}" hi 5
"${OUTPUT_PATH}" hi 5
The create main.cpp with this code:
使用以下代码创建 main.cpp:
int main(int argc, char** argv) {
cout << "First argument: " << argv[1] << endl;
cout << "Second argument: " << argv[2] << endl;
return 0;
}
Produces output:
产生输出:
First argument: hi
Second argument: 5
RUN SUCCESSFUL (total time: 320ms)
回答by Thesane
You can add multiple Run/Debug configuration for different arguments (or different executable) using Project Properties -> Run -> Manage Configurations -> New. Then you can add the commands/arguments there. In the main editor, the "Run" toolbar has a drop down that you can select desired configuration then you can use the Run/Debug button with this configurations
您可以使用项目属性 -> 运行 -> 管理配置 -> 新建为不同的参数(或不同的可执行文件)添加多个运行/调试配置。然后你可以在那里添加命令/参数。在主编辑器中,“运行”工具栏有一个下拉菜单,您可以选择所需的配置,然后您可以使用带有此配置的运行/调试按钮