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

What is the difference between void main and int main?

Best Answers

What is the difference? In C++, there is no difference, both are same. Both definitions work in C also, but the second definition with void is considered technically better as it clearly specifies that main can only be called without any parameter. read more

void main() Vs. int main(): main is a function with a special characteristic that the program execution always start from main. So the function main needs arguments and a return type. These int and void are its return type. read more

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

int main() and int main (void) are currently equivalent, since they are both function declarators and have no parameters. The following applies (6.7.6.3 ): 10 The special case of an unnamed parameter of type void as the only item in the list specifies that the function has no parameters. read more

Encyclopedia Research

Wikipedia:

Related Facts

Related Question Categories