main()的意义 [英] Significance of main()

查看:96
本文介绍了main()的意义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道main()在C / C ++程序中的意义是什么?

即使它是用户定义的函数,它也不像其他用户定义的那样灵活function?

Hi, I would like to know what is the significance of main( ) in C/C++ programs?
Even though it is a user defined function, it is not as flexibile as other user defined function?

推荐答案


您好,我想知道main()在C / C ++中的意义是什么程序?

即使它是用户定义的函数,它也不像其他用户定义的函数那样灵活?
Hi, I would like to know what is the significance of main( ) in C/C++ programs?
Even though it is a user defined function, it is not as flexibile as other user defined function?



它是用户定义的函数,但声明是C运行时的一部分。当你的程序开始执行时,它会做很多事情来初始化进程到你的代码可以执行的程度。一旦初始化完成(加载DLL,分配内存等),它就会调用main()。它期望一个整数返回,它被传回操作系统。它默认为零,所以你不必打扰如果你不想这样做。


Its a user defined function, but the declaration is part of the C run time. As your program begins to execute, its doing a whole lot of stuff to initialise the process to the point where your code can execute. Once the initialisation is complete (DLLs loaded, memory allocated etc) it calls main(). It expects an integer return, which is passed back the OS. Its defaulted to zero so you don''t have to bother if you don''t want to.



它默认为零所以如果你不想,你不必打扰。
Its defaulted to zero so you don''t have to bother if you don''t want to.



这是不对的,因为如果不从函数返回int,大多数编译器的主返回都会发出错误因此你总是不得不返回一个值。

This isn''t right, since main returns int most compilers will issue an error if you do not return int from the function therefore you always have to bother to return a value.



这是不对的,因为如果你不返回int,大多数编译器的主返回都会发出错误因此,您总是不得不费心去返回一个值。
This isn''t right, since main returns int most compilers will issue an error if you do not return int from the function therefore you always have to bother to return a value.



Stroustrup 3rd Ed 3.2节...

最小的C ++程序是......

int main (){}


Stroustrup 3rd Ed Section 3.2...
The minimal C++ program is...
int main() {}


这篇关于main()的意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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