• Welcome to Valhalla Legends Archive.
 

problem with simple prog

Started by Hamtaro, February 13, 2004, 04:07 PM

Previous topic - Next topic

K

Quote from: iago on February 16, 2004, 01:43 PM
Quote from: Skywing on February 16, 2004, 12:47 PM
main is a special case; you are not required to return a value for it.  This is not true for any other function with a non-void return type.

Your program will compile and run without main returning a value, but isn't it supposed to per the standard?  If you aren't going to return, why don't you just declare it void?  

If you don't specify a value, what is automatically returned?

According to the newest standard, if you omit a "return" from main, main is assumed to return 0.

Skywing

Quote from: iago on February 16, 2004, 01:43 PM
Quote from: Skywing on February 16, 2004, 12:47 PM
main is a special case; you are not required to return a value for it.  This is not true for any other function with a non-void return type.

Your program will compile and run without main returning a value, but isn't it supposed to per the standard?  If you aren't going to return, why don't you just declare it void?  

If you don't specify a value, what is automatically returned?
No, the standard says that main() is an exception and does not have to return a value.  I think 0 is assumed.  You cannot declare it as void, however.

Hamtaro

where do you find these standards at?

MrRaza


Eli_1

haha Raza, I don't think I'v seen you respond to anything with other than 'Google it'  ;D

Hamtaro

lol i did the google search before i asked the question :P

i found a standards site that was a .gov i think but i didnt actually see a document with the standards anywhere..

Grok

Quote from: Hamtaro on February 16, 2004, 09:31 PM
where do you find these standards at?

Skywing has insider information.

Grok

Quote from: Grok on February 18, 2004, 04:48 PM
Quote from: Hamtaro on February 16, 2004, 09:31 PM
where do you find these standards at?

Skywing has insider information.

Hamtaro:

"The C++ Programming Language" by Bjarne Stroustrup for standards of C++.

|