Difference between void and non void functions

Viewed 52

So I get that a void function won't return a value, while a int one for example will return an integer. So void main(){} doesnt return, but int main(){return 0;} will return.

My question is, what is the difference between these 3 functions. I know the first one wont return a value, the second one will return an integer. But how about the third one? I know it returns an integer because I've tested it, so what does that (void) does? Why is is there? void main(){} int main(){return 0;}; int main(void){return 0;};

I'm a begginer so sorry if it sounded confusing... Thanks in advance!!

(The question is about the programming language C)

1 Answers

Between the parenthesis are the parameters to the function.

In a function definition, the proper way to designate a function that takes no parameters is to simply specify void for the parameter list.

An empty parameter list (in a definition) is also a way of saying the function takes no parameters, however this syntax is considered deprecated and should not be used in new programs.

Related