什么是INT主要()的返回值的含义,以及如何显示呢? [英] What's the meaning of the return value of int main(), and how to display it?

查看:595
本文介绍了什么是INT主要()的返回值的含义,以及如何显示呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  

可能重复:结果
  什么都要用C的main()的返回/ C ++?


我用C有这个简单的程序:

 的#include<&stdio.h中GT;诠释的main()
{
  返回8;
}

什么是返回值的含义,以及如何显示它,或者如何使用它?


解决方案

  

什么是返回值的含义是什么?


这是用来的main()功能的状态返回到调用者的main()

参考:结果
C ++ 03标准:18.3启动和终止


  

最后,控制被返回到主机环境。 如果状态是零或EXIT_SUCCESS,一个
  状态成功终止执行定义的形式返回
如果状态
  EXIT_FAILURE,状态成功终止的实现定义的形式返回

  否则,返回的状态是实现定义的。


  
  

如何显示它,或者如何使用它?


就像你显示或使用任何其他函数返回值。 的main()在C / C只是另一个函数++没有什么特别的地方在主要方面。

Possible Duplicate:
What should main() return in C/C++?

I have this simple program in C:

#include <stdio.h>

int main()
{
  return 8;
}

What's the meaning of the return value, and how to display it, or how to use it?

解决方案

What's the meaning of the return value?

It is used to return the status of the main() function to the caller of main():

Reference:
C++03 Standard: 18.3 Start and termination

Finally, control is returned to the host environment. If status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. If status is EXIT_FAILURE, an implementation-defined form of the status unsuccessful termination is returned. Otherwise the status returned is implementation-defined.

how to display it, or how to use it?

Just as you would display or use return value of any other function. main() is just another function in C/C++ there's nothing special about main in that regards.

这篇关于什么是INT主要()的返回值的含义,以及如何显示呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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