Link to home
Start Free TrialLog in
Avatar of mitchguy
mitchguy

asked on

difference between int main( ) and int main (void)

is there a difference between int main( ) and int main (void)?
ASKER CERTIFIED SOLUTION
Avatar of poclea
poclea

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mitchguy
mitchguy

ASKER

When I had a C++ class a few years ago the lab assistant
said there was a difference, but didn't want to go into the details since it might add confusion to someone who is just learning. It just recently occured to me that I never found out what the difference was. I believe that there is a difference. Or at least there must be more to it than that.
I think I found the information I was looking for and since this is a c++ forum your answer is accuarate.
I found the following explanation in a help tutorial

A function prototype with an empty parameter list, such as
    extern void func();

means in C that the argument list of the declared function is not prototyped: the compiler will not be able to warn against improper argument usage. When declaring a function in C which has no arguments, the keyword void is used, as in:
    extern void func(void);

Because C++ enforces strict type checking, an empty parameter list is interpreted as the absence of any parameter. The keyword void can then be omitted: in C++ the above two declarations are equivalent.