The program entry point in C is the void main function, whose main purpose is to declare the entry point, create an execution environment and call other functions to execute program logic. This function does not return any value (void), the function name is main, and the return type is int (usually returning 0 indicates a normal exit).
void main in C
In C, the void main
function is a program The entry point is also the starting point of program execution.
Purpose
##void main The main purpose of the function is:
Syntax
void main The syntax of the function is as follows:
<code class="c++">int main(void)</code>
: The specified function does not return any value.
: Function name. In C, the
main function name is predefined and cannot be changed.
Return type
void main The return type of the function is
int, indicating that the function returns an integer. Normally returns 0 when the program exits normally.
Example
The following is a simple C program containing thevoid main function:
<code class="c++">#include <iostream> void main() { std::cout << "Hello, world!" << std::endl; }</code>
Note Matter
function does not need to declare a return type.
The function has no parameters because no parameters need to be passed to start the program.
as the entry point of the program, which is the same as
void main, But it is more in line with the conventions of C language.
The above is the detailed content of What does void main mean in c++. For more information, please follow other related articles on the PHP Chinese website!