Why don’t we use (void) in main?

I’m not sure what the standards are nowadays, but in traditional ANSI C, using empty parentheses indicates that the function can take any number of arguments. Declaring a void parameter on the other hand indicates that the function only takes zero arguments. In this case (and many others), it really doesn’t matter too much.

If you want to be strict though, it’s probably best to define the void parameter. Of course, the main function can also be defined as int main(int argc, const char* argv[]) – which is perfectly valid, but often unnecessary if you don’t care about arguments.

Leave a Comment