A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

When do we use int main() and void main() in C?

Best Answers

In C++, both fun() and fun(void) are same. So the difference is, in C, int main() can be called with any number of arguments, but int main(void) can only be called without any argument. Although it doesn't make any difference most of the times, using “int main(void)” is a recommended practice in C. read more

The overwhelming majority of the time, one of int main(void) or int main(int argc, char* argv[]) is what you need to use. In particular, if you're writing a program that's going to be compiled by any major compiler for running on a personal computer, with the full set of the C standard libraries, then you almost certainly need to be returning an int from main. read more

Neither main() or void main() are standard C. The former is allowed as it has an implicit int return value, making it the same as int main(). The purpose of main's return value is to return an exit status to the operating system. read more

Actually, ‘main’ is the parent function of all the functions in C. If we don't need any return value we use return type 'void'. We can also use ' int' as a return type. After all ‘main()’ is also a function, there is a flexibility of mentioning return type to it by user. read more

Encyclopedia Research

Wikipedia:

Related Facts

Related Question Categories

Further Research