main-return ???

I

# include

what is the ((((return any no;))) in the main mean plz
Ex.
int main()
{

;
;
;
return ??;

}
 
D

David Paleino

# include ha scritto:
what is the ((((return any no;))) in the main mean plz
Ex.
int main()
{

;
;
;
return ??;

}

That's the "exit code".

For example, a "return 0" or "return EXIT_SUCCESS" means that no errors
occured.

You could also google for "exit codes", and see if there's anywhere a
list available (I don't really know, sorry)

Hope this helps,

David
 
V

Vladimir S. Oka

# include said:
what is the ((((return any no;))) in the main mean plz
Ex.
int main()

int main(void)

is better, as it spells out your intention.
{

;
;
;
return ??;

}

You should try and make your questions clearer.

My guess is that you want to know how to return a value from `main()`.
As `main()` returns an `int`, you can use any expression that returns
that type (including implicit promotion). E.g. given:

int i = 42;
double x = 42.0;

all of the following are OK:

return 0;
return 37+5;
return i;
return x;
return (int)x;
return EXIT_SUCCESS;
return EXIT_FAILURE;

As for the meaning of the value returned, 0 means success, as well as
EXIT_SUCCESS. You should indicate failure using EXIT_FAILURE. How the
underlying OS (if any) interprets these values is outside the scope of
the C Standard. Both are defined in <stdlib.h>.
 
K

Keith Thompson

# include said:
what is the ((((return any no;))) in the main mean plz
Ex.
int main()
{

;
;
;
return ??;

}

I'm guessing that "no" means "number", and "plz" means "please". If
you took the time to spell out the words, I wouldn't have to guess.
Abbreviations like that make what you write more difficult to read.

As for the value returned by main, any decent C textbook or tutorial
should answer this elementary question.
 
M

Malcolm

David Paleino said:
# include ha scritto:

That's the "exit code".

For example, a "return 0" or "return EXIT_SUCCESS" means that no errors
occured.

You could also google for "exit codes", and see if there's anywhere a
list available (I don't really know, sorry)
A portable program can return 0 (success), EXIT_SUCCESS (success) or
EXIT_FAILURE (terminate without accomplishing intended purpose).

Other codes are platform-dependent.
 
R

robin liu

It says that the main function must return a int type code, default 0
indicate successful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,947
Members
47,498
Latest member
yelene6679

Latest Threads

Top