In C programming sometimes I see int main(void) and then int main () So what is the difference?
there is no difference, "void" means you are not going to take arguments. so either way is ok.
int main(void) means your your main is an integer type, logically you have to return an integer value so you have to put return 0 at the end of the function. the parameter void means you are not passing any value. int main() is just the same as int main(void).
@pangyaPrice thats correct
In C, each function header has 3 sections: the type of date that the function returns, the name of the function, the argument list being passed to the function when it's called. main() is a function, slightly different than others, but still a function. main() syntactically should be: int main( int argc, char* argv[] ) argc is the number of command line arguments that were used calling the program, argv[] is the array of those args. So in the case of a command like: cd Desktop argc = 2, argv[ 0 ] = "cd", argv[ 1 ] = "Desktop". If no command line arguments are expected, programmers will just skip the argc/argv stuff. Leaving it blank raises the question to anyone reading the code "Is this blank on purpose?", so some programmers will put void in to indicate "yeh, I meant to do this".
Join our real-time social learning platform and learn together with your friends!