什么是这个主要的功能? [英] what is this main fucntion?

查看:85
本文介绍了什么是这个主要的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白主要功能?





i don't understand the main function?


#include <iostream.h>
int main()
{
cout<<"Hello"/n;
 return 0;
}



1)这个主要功能是什么?

2)为什么使用这个主要功能?

3)这个返回0是什么?


1) what is this main function?
2) why is this main function used?
3) what is this return 0?

推荐答案

每个程序都需要 main 函数 - 它是程序开始执行的地方 - 称为程序的入口点。 (虽然在某些程序中,例如Windows Forms,这个功能通常是隐藏的,因为你不需要改变它。)



当你运行程序时,它从main函数的第一行开始,当你离开main函数时(通过执行其中的最后一条指令并通过结束的大括号,或通过执行 return 声明)你的程序终止。



如果您为 return 语句提供一个数字,那就是所谓的返回代码错误代码,系统(和其他应用程序)将其解释为显示程序是成功还是失败。值为零表示良好或正常退出,非零值通常是一个代码,用于解释无法正常退出的原因。例如,值为2通常表示找不到文件
Every program needs a main function - it is where your program begins to execute - known as the entry point for the program. (Though in some programs such as Windows Forms, the function is normally hidden from you as you don't need to change it).

When you run your program, it starts with the first line in the main function, and when you leave the main function (either by executing the last instruction in it and falling out through the closing curly bracket, or by executing a return statement) your program terminates.

If you supply an number to the return statement, that that is known as the return code or the error code and it is interpreted by the system (and other apps) as showing if the program succeeded or failed. A value of zero indicates a good, or normal exit and a non-zero value is normally a code which explains why it failed to exit normally. For example, a value of two will often mean "file not found"


请参阅下面的链接

主要功能说明 [ ^ ]

链接1 [ ^ ]
Refer Below Link
Main Function Description[^]
Link 1[^]


1)这个主要功能是什么?

入口点 - 第一行执行

Main是线程并且随着线程启动应用程序启动,线程结束应用程序结束(您的应用程序是一个进程 - 请参阅任务管理器,它将在运行时显示您的应用程序进程列表。)


2)为什么使用这个主函数?

因为C ++的开发人员设置了主要功能将是应用程序代码将开始工作的块

如果他们想要那个时间它可以是任何


就像你正在制作自己的语言一样,你会告诉编译器,当编译器读取它时,假设START字是你的第一行执行,那么它应该开始理解逻辑并将其表示给用户。



3)这个返回0是什么?

运行时使用main()函数的返回值library作为进程的退出代码。 Unix和Win32都支持在进程完成后从进程返回的(小)整数的概念。

所以,...简而言之,这是关于程序终止的指示

假设您正在使用调用其他exe(可以返回值)的程序

并且您正在接收它然后根据该结果决定是否进行下一步。

参见示例

http://stackoverflow.com/questions/5728196/how-to-get-return-value -from-exe-and-restart-it [ ^ ]





希望它解决了你的难题

快乐编码!

:)
1) what is this main function?
entry point - First line of execution
Main is thread and as the thread start your application start as the thread end your application ends (your application is a process - see task manager it will show your app in process list while it's running.)

2) why is this main function used?
because developers of C++ had set that main will be the block inside which application code will be start working
it could be any if they wanted that time

like you are making your own language you will tell your compiler that suppose START word will your first line of execution when compiler read it then it should start to understand logic and represent it to user.

3) what is this return 0?
the return value from the main() function is used by the runtime library as the exit code for the process. Both Unix and Win32 support the concept of a (small) integer returned from a process after it has finished.
so,.. in short it's a indication about termination of program
suppose you are working with a program that call other exe (which can return value)
and you are receiving it then decide whether to do next step or not based on that result.
see example
http://stackoverflow.com/questions/5728196/how-to-get-return-value-from-exe-and-restart-it[^]


Hope it has solve your difficulty
Happy Coding!
:)


这篇关于什么是这个主要的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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