int main vs void main

Submitted By: shantanugoel
Rating: starstarstar (Rate It)
Share: Share By Email By Email

Visit


Description

This is an article about the most common mistake that most C/CPP programmers make and clarifies the doubt that they have about the issue which is the correct form to use.

Comments (8)

Good starstarstarstar   Posted by: bilderbikkel on Monday, March 16, 2009

The message is good. The reasoning behind it, however, not as detailed is I would've liked it: the reader is told that it has something to do with 'startup code', but this is not explained in detail. This would not be a problem, had there have been links to a more detailed article, which results me in giving four instead of five stars.

Incorrect article star   Posted by: Lundin on Tuesday, September 08, 2009

The article is not correct. Both C and C++ allows void main() in freestanding environments, ie code for embedded systems, operative systems etc. Still, such versions of main() in freestanding environments are implementation-defined behavior and not necessarily portable because of it.

On hosted environments (Windows, DOS, Linux, Mac etc programs), the only allowed form in both C and C++ is int main(). There is no difference between the two languages.

As for the "startup code", it is generated by the compiler as well, so typically it doesn't matter whether standard or non-standard main() is used. So the biggest program with non-standard main() is that it's non-portable.

just a try starstarstarstar   Posted by: FreshBirdFirstTimeToHere on Thursday, April 15, 2010

first time to visit a full English Website on progamming,
It's not as hard as I thought before I click the link

C &C++ starstar   Posted by: AJAY KUMAR on Thursday, July 01, 2010

DISTINGUISH BETWEEN INT MAIN() AND VOID MAIN()

int main vs void main starstar   Posted by: Akshay on Monday, October 04, 2010

c language starstarstarstarstar   Posted by: lala on Saturday, October 09, 2010

c is very very logical thinking language

C Language starstarstarstar   Posted by: Himanshu Madhan on Friday, November 26, 2010

It is the interesting language

sites starstarstar   Posted by: Arindam on Saturday, January 08, 2011

http://grepler.com/threads/index/alt.comp.lang
http://grepler.com/threads/index/alt.comp.lang.php

Add Your Rating

(Not published)
star
starstar
starstarstar
starstarstarstar
starstarstarstarstar
 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.