main函数的原型,包括完整的参数返回类型等。

villastoner 2002-08-15 10:53:24
thanks
...全文
328 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
fangrk 2002-08-18
  • 打赏
  • 举报
回复
是的,我写错了,应该是,**argv 或者*argv[] (两者一样的)
pi1ot 2002-08-15
  • 打赏
  • 举报
回复
菜刀阿,**argv 和*argv[] 有什么不一样吗??
villastoner 2002-08-15
  • 打赏
  • 举报
回复
TO: fangrk(加把油,伙计!)

第二个参数应该是*argv[]吧?
kwok_1980 2002-08-15
  • 打赏
  • 举报
回复
all upers's are OK !
shine0123 2002-08-15
  • 打赏
  • 举报
回复
int main(int argc,char *[]argv)

argc代表参数个数
argv代表参数字符串
fangrk 2002-08-15
  • 打赏
  • 举报
回复
int main(int argc,char *[]argv)

argc代表参数个数
argv代表参数字符串
比如:
myprogram c:\a.txt c:\b.txt
则:argc==3
argv[0]=="myprogram"
argv[1]=="c:\\a.txt"
argv[2]=="c:\\b.txt"
guoming1 2002-08-15
  • 打赏
  • 举报
回复
int main(int argc,char argv[])
cwanter 2002-08-15
  • 打赏
  • 举报
回复
main( int argc, char *argv[ ], char *envp[ ] )
{
program-statements
}

wmain( int argc, wchar_t *argv[ ], wchar_t *envp[ ] )
{
program-statements
}

The main function marks the beginning and end of program execution. A C or C++ program must have one function named main. If your code adheres to the Unicode programming model, you can use the wide-character version of main, which is wmain.

The main and wmain functions can take the following three optional arguments, traditionally called argc, argv, and envp (in that order):

argc

An integer specifying how many arguments are passed to the program from the command line. Because the program name is considered an argument, argc is at least 1.

argv

An array of null-terminated strings. It can be declared as an array of pointers to char (char *argv[ ] or wchar_t *argv[ ] for wmain) or as a pointer to pointers to char (char **argv or wchar_t **argv for wmain). The first string (argv[0]) is the program name, and each following string is an argument passed to the program from the command line. The last pointer (argv[argc]) is NULL.

Microsoft Specific —>

envp

A pointer to an array of environment strings. It can be declared as an array of pointers to char (char *envp[ ]) or as a pointer to pointers to char (char **envp). If your program uses wmain instead of main, use the wchar_t data type instead of char. The end of the array is indicated by a NULL pointer. The environment block passed to main and wmain is a “frozen” copy of the current environment. If you subsequently change the environment via a call to putenv or _wputenv, the current environment (as returned by getenv/_wgetenv and the _environ/ _wenviron variable) will change, but the block pointed to by envp will not change. This argument is ANSI compatible in C, but not in C++.

END Microsoft Specific

villastoner 2002-08-15
  • 打赏
  • 举报
回复
第二个参数是二级批针吗
dgj 2002-08-15
  • 打赏
  • 举报
回复
int main(int argc,char **argv)

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧