问题描述
在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 ++应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!