Solved

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

Posted on 2002-07-12
3
1,012 Views
Last Modified: 2010-05-18
is there a difference between int main( ) and int main (void)?
0
Comment
Question by:mitchguy
  • 2
3 Comments
 

Accepted Solution

by:
poclea earned 50 total points
ID: 7149183
There is no difference. The compiler automatically replaces a int main() declaration with int main(void).
0
 

Author Comment

by:mitchguy
ID: 7149729
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.
0
 

Author Comment

by:mitchguy
ID: 7149783
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now