The reason you put ‘void’ isn’t to help the compiler, it’s to help whoever is reading/using your code. Often, functions will be declared before they are defined. This lets the programmer and other functions know the required syntax for a function call without needing the full definition.
Let’s say I have the following method declared (without void):
OrderAPizza(char *pizza, int numToppings);
If someone comes along and wants to use the function, they will have to search for the definition to figure out what it returns, if anything. Maybe it returns the cost of the pizza, or an order number, or an error code. Even if the compiler could figure it out, just adding a ‘void’ to the front lets the programmer know they don’t need to check anything.
As far as putting ‘void’ in the arguments list to indicate no arguments, that is a matter of taste. I think empty parenthesis are enough to indicate no arguments.
in a similar but unrelated issue:
You will find that some people will not declare parameter names. The compiler allows this as long as the definition contains the names. This is often frustrating to someone trying to understand the code.
For Instance, using the above declaration:
void OrderAPizza(char *, int);
The compiler is more than happy with this declaration and will proceed without problems. But if you don’t leave any comments telling the coder what the first and second arguments are for, you are the devil. Self-explanatory code is way more efficient and effective than needing comments for everything.