Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2002-07-12
3
Medium Priority
?
1,019 Views
Last Modified: 2010-05-18
is there a difference between int main( ) and int main (void)?
0
Comment
Question by:mitchguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
poclea earned 150 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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.
Suggested Courses

618 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