爱问知识人 爱问教育 医院库

main()中的返回值是怎么回事

首页

main()中的返回值是怎么回事

main()中的返回值是怎么回事,请详尽说说

提交回答
好评回答
  • 2019-03-12 20:42:26
      Whyisvoidmain()wrong?Themain()functionistheentrypointofaC/C++program。Thereforeithastofollowsomeconventionssotheruntimesystemcancallitcorrectly。
      ModernC++ ()(intargc,char*argv[])(intargc,char**argv)(Thereisnorealdifferencebetweenthelasttwo)Somain()returnsalwaysanint,andtakeseithernoneorthetwoparametersargcandargv;voidmain()wasabandondedlongtimeagoandmusn'tbeusedintodayscode(Butsomecompilerareacceptingitforbackwardcompatibility)Sinceoftenyoudon'tneedthevaluereturnedbymain()thereisabigexcep()functiondoesn'tendwithareturn;thecompilersilentlyinsertsareturn0;。
      So:(){}isperfectvalidC++,:intf(){}isnot,becauseofthemissingreturn(whilenotstrictlyforbidden,amissingreturnisacommonsourceoferrorandbadstyle。
      Mostcompilerswarnaboutit)。

    我***

    2019-03-12 20:42:26

其他答案

类似问题

换一换
  • C/C++ 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 176-195
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):