int main(int argc, char** argv) [英] int main(int argc, char** argv)

查看:21
本文介绍了int main(int argc, char** argv)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重复:
main 的正确声明是什么?

main 函数中的参数是什么意思?他们想告诉我们什么?

What do we mean by the arguments in this main function? What are they trying to tell us?

int main(int argc, char** argv)

更新: 而且,前面的代码行是否与此 int main(int argc, char* argv[]) 类似?如果是这样,我们怎么能说 char** argvchar* argv[] 相似,因为它们从 array 观点?

UPDATE: And, is the preceding line of code similar to this int main(int argc, char* argv[])? If so, how can we say that char** argv is similar to char* argv[] as they don't look similar from an array point of view?

它与没有任何参数的 int main() 相比如何?

How is it compared with int main() which does not have any arguments?

谢谢.

推荐答案

argc 参数是在调用可执行文件时指定的命令行选项数,包括可执行文件名称.各个命令行选项位于 argv 数组中,该数组以 NULL 结尾(用于调用可执行文件的名称和路径在 argv[0]).

The argc parameter is the number of command line options specified, including the executable name, when the executable was invoked. The individual command line options are found in the argv array, which is NULL terminated (the name and path used to invoke the executable is in argv[0]).

这两个版本的区别很简单,就是你是否想解析命令行参数——如果你对它们不感兴趣,那么你可以使用第二种形式忽略它们.

The difference between the two versions is simply if you want to parse command line arguments or not - if you are not interested in them then you can ignore them using the second form.

这篇关于int main(int argc, char** argv)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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