What is the difference between "int main(void)" and simply "int main()"? Is "int main()" acceptable?
MareoRaft
0
Junior Poster in Training
Recommended Answers
Jump to Postyes, it has no difference, but you should always use the int main(int nargs, args[]);, it is better then just int main()
Jump to PostI like programs that support command line arguments. There, there's my opinion, now I'll just brace for the backlash.....
Jump to Postwhat about void main()?
Not portable at best, undefined behavior at worst.
Working fine for me...
You'll find that "it works for me" is not synonymous with "it's correct" in C++. There are a lot of broken things that appear to work when you test, but can and do blow …
Jump to PostWow are we really having a 4 page long thread about this. I don't get whats the problem. You guys/girls/its needs to get some fresh air and forget this thread ever happened
Jump to PostIt's worse to use "int main(int argv, char** args)" because you loose two variable names if you won't use command line arguements or if the system does not support it .)
Luckily there's literally 1.1478385914378332077745140144861e+457 other variable names to choose from.
…I was talking to zeronis, not you. He said...
All 43 Replies
sergent
52
Posting Pro
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Narue
5,707
Bad Cop
Team Colleague
frogboy77
73
Posting Pro in Training
Rajesh R Subram
127
Junior Poster in Training
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
ravenous
266
Posting Pro in Training
Rajesh R Subram
127
Junior Poster in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
invisal
381
Search and Destroy
mrnutty
761
Senior Poster
Rajesh R Subram
127
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
Rajesh R Subram
127
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
pseudorandom21
166
Practically a Posting Shark
Narue
commented:
Me too. :) Console filters aren't common anymore, but they're super useful.
+17
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Rajesh R Subram
127
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
zeronis
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
skatamatic
371
Practically a Posting Shark
Narue
5,707
Bad Cop
Team Colleague
Voynex
-4
Newbie Poster
skatamatic
371
Practically a Posting Shark
sergent
52
Posting Pro
Narue
5,707
Bad Cop
Team Colleague
skatamatic
371
Practically a Posting Shark
Narue
5,707
Bad Cop
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.