首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

关于主调用函数解决思路

2012-02-22 
关于主调用函数1)一般来说,是不是有这两种标准的形式:intmain()与intmain(intargc,charargv)。恩,那什么时

关于主调用函数
1)一般来说,是不是有这两种标准的形式:int   main()与int   main(int   argc,char   argv)。恩,那什么时候用到后面那种形式的调用呢?


[解决办法]
一个简单的例子

int main(int argc, char* argv[])
{
if (argc > 2)
{
cout < < "Error, print \ "Startup -help\ " for usage. " < < endl;
return 0;
}

if (argc == 2 && strcmp(argv[1], "-help ") == 0)
{
cout < < "Usage: Startup for starting up test. " < < endl;
cout < < "------------------------------------------- " < < endl;
cout < < "Startup: Start the application. " < < endl;
cout < < "Startup -v: View the version. " < < endl;
cout < < "Startup -d: Start the application in debug mode. " < < endl;
cout < < "Startup -h: Start the application in hide mode. " < < endl;
cout < < "Startup -k: Stop the application running in hide mode. " < < endl;
cout < < "Startup -l: Reload the config when running in hide mode. " < < endl;
return 0;
}

return 0;
}

这样输入Startup -help便会显示提示信息
事实上,还可能有第三个参数,用来配置环境变量的。

热点排行