Solved

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

Posted on 2002-07-12
3
1,017 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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. …
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

724 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