如何将参数传递给C ++应用程序 [英] How to pass an argument to the C++ application

查看:102
本文介绍了如何将参数传递给C ++应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,您可以使用void main(String[] args)传递参数.

In Java you can pass an argument with void main(String[] args).

在Eclipse中找到run configuration,放置参数并运行程序,但是在C ++中,只有int main()如何使用Visual Studio 2010将参数传递给程序?

Find run configuration in Eclipse, put arguments and run a program, but in C++ there is just int main() how to pass arguments to the program using Visual Studio 2010?

推荐答案

虽然int main()是正确的,但是您可以使用int main(int argc, char *argv[])int main(int argc, char **argv)来获取argc和char数组数组的参数计数(字符串)与argv.

While int main() is correct, you can use int main(int argc, char *argv[]) or int main(int argc, char **argv) to get the argument count with argc and an array of char arrays (strings) with argv.

请注意,第一个参数将始终是您正在运行的程序的路径.

Please note that the first argument will always be the path to the program you are running.

这篇关于如何将参数传递给C ++应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆