在 Eclipse 中使用 argc 和 argv?
我有一个工作程序,但现在我必须对 main
使用 int argc
和 char *argv[]
参数。每当我尝试这样做时,它都会给我带来无法保存的错误。有没有办法让 argc 和 argv 在 Eclipse 中工作?
I have a working program but now I have to use the int argc
and char *argv[]
parameters to main
. Whenever I try to do this it gives me errors that it cannot save. Is there any way to make argc
and argv
work in Eclipse?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你的问题是,当你通过 eclipse 执行它时,你不知道如何将参数传递给你的程序,不是吗?
如果这就是您想要的,请阅读以下内容。
单击“项目->属性”,然后在“运行/调试设置”中单击“新建按钮”。选择 C++ 应用程序。这里你可以看到有4个选项卡,第二个选项卡称为“arguments”。
在此选项卡中,您可以看到一个文本区域。在那里输入您的应用程序的参数,然后单击“确定”。
当您通过 Eclipse 的“播放”按钮执行应用程序时,您的程序将被带参数调用。
I guess your problem is that you don't know hot to pass argument to you program, when you execute it through eclipse isn't it ?
If that is what you want, read the following.
Click on the "Project->Properties" then in "Run/Debug settings" click on the "New button". Choose C++ application. Here you can see that there are 4 tabs, and the second tab is called "arguments".
In this tab you can see a textarea. Type your application's argument there, and click "OK".
When you will execute your application thanks to the "play" button of eclipse, your program will be called with arguments.