int main(void) { }
Here, you are telling your compiler explicitly that your main()
function is not going to take any arguments. This prototype of main()
function is standard.
int my_func(void)
{
return 100;
}
// the above function can be called as:
// 1. my_func(); --> good
// 2. my_func(21); --> error
// 3. my_func("STACKOVERFLOW"); --> error
int main() { }
Here, you are telling your compiler implicitly that your main()
function is not going to take any arguments. But, there's a plot twist, in C
leaving the function without any arguments (type function() { }
) means you can put any value/variable in it while calling that function. This prototype should be avoided.
int my_func()
{
return 100;
}
// the above function can be called as:
// 1. my_func(); --> no error
// 2. my_func(21); --> no error
// 3. my_func("STACKOVERFLOW"); --> no error