0 Fayazur Rahman Summit · April 7, 2015
why some people use '"void'" in the main function ?

Post a Reply


Oldest  Newest  Rating
0 Fayazur Rahman Summit · April 11, 2015
Thank you sooooo much Franz Schmidt
0 c student · April 8, 2015
int main (void) { /* ... */ }

specifies no arguments for main.
int main () { /* ... */ }

specifies any number of arguments.
0 Franz Schmidt · April 7, 2015
because in fact you never do return a value at any time in your main
if i would use int main i would need to return a integer somewhere in the program as return value
therefore often you see at the end "return 0;" or something like that.
int main(){
//do your code

return 0;

if you use void you don't need the return 
void main(){
//do your code

basically it works in both ways and it also doesn't matter if you don't return a value but it as good programming practice always to return a value when a datatype is set or use void instead
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator