A structured lesson workspace with readable content, hands-on examples, and a clean path to completion.
In C, int main() and int main(void) are not the same declaration. An empty parameter list in C means the function takes an unspecified number of arguments. It does not mean zero arguments. int main(void) explicitly declares zero parameters. In C++, they are identical: empty means void. In C, the distinction matters for type checking. A caller could legally call main(42) if main is declared with empty parentheses. With void, the compiler rejects it.
#include <stdio.h>void no_args() {printf("no_args called\n");}void zero_args(void) {printf("zero_args called\n");}int main(void) {no_args();no_args(42, "extra");zero_args();return 0;}
no_args(42, "extra") compiled with no warning because the empty parameter list means unspecified arguments. The compiler does not check. zero_args(42, "extra") produced a warning because void explicitly means zero parameters. In C23, empty parentheses finally mean void, aligning C with C++. But for code targeting C17 and earlier, write void.
Always write int main(void) when your program does not use command-line arguments. Always write int main(int argc, char *argv[]) when it does. Never write int main() with empty parentheses in C code targeting C17 or earlier. The void is two characters that give you type checking. The empty parens give you nothing except a potential silent bug.
This is a C-specific quirk that trips up people arriving from C++, Java, or Python. In those languages, empty means zero. In C, empty means "I am not telling you." Write void. Be explicit. The compiler will protect you. Next: why void main() is wrong and what it actually does.
Finish the lesson once you have worked through the material. This awards ★ 20 XP.