Home >Backend Development >C#.Net Tutorial >The difference between int main and void main

The difference between int main and void main

藏色散人
藏色散人Original
2020-04-26 11:09:5629600browse

The difference between int main and void main

There are two standard main functions:

int main(void) //不需要参数
int main(int argc, char *argv[]) //需要参数,argc为给程序的参数的个数,argv中保存的是给函数的参数,都是字符串。

Both need to return a value so that the user can know whether the program is executed correctly.

Other types of main functions are non-standard. For example, under Linux, the standard main function is used, while many compilers under Windows use void main() or main(). In fact, this kind of non-standard main function is very bad. People who use this kind of main function to learn C language cannot know how the system passes parameters to the program.

The difference between int main and void main

1. The difference is whether the main() function has a return value.

2. The function defined by void has no return value, and the function defined by int returns an integer value.

3. Void literally means "no type". It is often used in programming to declare parameter types, return values, and pointer types in functions. It has the function of annotating and limiting the program.

Recommended: "c Language Tutorial"

The above is the detailed content of The difference between int main and void main. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn