Home > Article > Backend Development > 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!