C++ main函数

微软解释:https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args?redirectedfrom=MSDN&view=vs-2019

All C++ programs must have a main function. If you try to compile a C++ .exe project without a main function, the compiler will raise an error. (Dynamic-link libraries and static libraries don't have a main function.) The main function is where your source code begins execution, but before a program enters the main function, all static class members without explicit initializers are set to zero. In Microsoft C++, global static objects are also initialized before entry to main. Several restrictions apply to the main function that do not apply to any other C++ functions. The main function:

  • Cannot be overloaded (see Function Overloading).
  • Cannot be declared as inline.
  • Cannot be declared as static.
  • Cannot have its address taken.
  • Cannot be called.

所有C++程序都必须含有一个main函数。

argc
An integer that contains the count of arguments that follow in argv. The argc parameter is always greater than or equal to 1.

argv
An array of null-terminated strings representing command-line arguments entered by the user of the program. By convention, argv[0] is the command with which the program is invoked, argv[1] is the first command-line argument, and so on, until argv[argc], which is always NULL. See Customizing Command Line Processing for information on suppressing command-line processing.

The first command-line argument is always argv[1] and the last one is argv[argc - 1].

第一个参数argc:参数个数

第二个参数argv:参数组

 

原文链接: https://www.cnblogs.com/zebra-bin/p/13230585.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;

也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬

    C++ main函数

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/361771

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年3月2日 下午2:00
下一篇 2023年3月2日 下午2:01

相关推荐