473,467 Members | 1,514 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

return from main

Guys,

Can I return 0, from main() ? Is this equivalent to
exit(EXIT_SUCCESS) ?

thanks for any help...

Nov 12 '07 #1
27 2453
ju**********@yahoo.co.in said:
Guys,

Can I return 0, from main() ?
Yes.
Is this equivalent to exit(EXIT_SUCCESS) ?
Yes in practice. In theory, EXIT_SUCCESS and 0 both represent successful
termination but the Standard doesn't forbid them from having different
values and representing different kinds of success! (I don't know of any
implementations that distinguish between them in this way, and it is
likely that there are no such implementations.)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Nov 12 '07 #2
"ju**********@yahoo.co.in" <ju**********@yahoo.co.inwrites:
Can I return 0, from main() ? Is this equivalent to
exit(EXIT_SUCCESS) ?
<http://c-faq.com/>, question 11.16, or read any decent C reference.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 12 '07 #3
Richard Heathfield <rj*@see.sig.invalidwrites:
ju**********@yahoo.co.in said:
>>
Can I return 0, from main() ?

Yes.
>Is this equivalent to exit(EXIT_SUCCESS) ?

Yes in practice. In theory, EXIT_SUCCESS and 0 both represent successful
termination but the Standard doesn't forbid them from having different
values and representing different kinds of success! (I don't know of any
implementations that distinguish between them in this way, and it is
likely that there are no such implementations.)
Obscure exceptions: recursive calls to main() and atexit()-registered
functions that refer to local variables declared in main().

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 12 '07 #4
ju**********@yahoo.co.in wrote:
Guys,

Can I return 0, from main() ? Is this equivalent to
exit(EXIT_SUCCESS) ?

thanks for any help...
According to Google Groups, you (or someone using your
alias) have been participating in comp.lang.c since February
of 2004. Since you are still asking basic, first-ten-days
questions after more than four and a half years, I suspect
your abilities lie elsewhere than in computer programming
and I urge you to seek a different sphere of activity.

Or just to stop trolling.

--
Eric Sosman
es*****@ieee-dot-org.invalid
Nov 12 '07 #5
On Nov 12, 6:30 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrote:
junky_fel...@yahoo.co.in wrote:
Guys,
Can I return 0, from main() ? Is this equivalent to
exit(EXIT_SUCCESS) ?
thanks for any help...

According to Google Groups, you (or someone using your
alias) have been participating in comp.lang.c since February
of 2004. Since you are still asking basic, first-ten-days
questions after more than four and a half years, I suspect
your abilities lie elsewhere than in computer programming
and I urge you to seek a different sphere of activity.

Or just to stop trolling.
First of all, Sorry, for asking the similar and such basic questions
again and again.

The reason why I asked this question is because I was not able to
undertand the following lines (mentioned in n1124.pdf at page 13.

"If the return type of the main function is a type compatible with
int, a return from the
initial call to the main function is equivalent to calling the exit
function with the value
returned by the main function as its argument;10) reaching the } that
terminates the
main function returns a value of 0. If the return type is not
compatible with int, the
termination status returned to the host environment is unspecified."

The wordings are really confusing. Whenever, I read these lines, I
endup in one or other kind of confusion.
Still, the meaning is unclear to me.

Nov 13 '07 #6
ju**********@yahoo.co.in wrote:
The reason why I asked this question is because I was not able to
undertand the following lines (mentioned in n1124.pdf at page 13.
If I reformat and comment, does it help?
"If the return type of the main function is a type compatible with
int,
i.e. if your code starts with int main(<something>)
(and it must in a hosted environment, as I understand it)
a return from the initial call to the main function is
equivalent to calling the exit function with the value
returned by the main function as its argument;
i.e. return(x) in main is equivalent to exit(x)
(in the initial call - recursive calls are, naturally, different)
reaching the } that terminates the main function returns
a value of 0.
i.e. dropping off the bottom of main() is equivalent to exit(0)
If the return type is not compatible with int, the
termination status returned to the host environment is unspecified."
That should be clear.

(I do wonder whether you should really be spending much time on
reading the standard - a good reference text may be much more useful
to you.)
Nov 13 '07 #7
Keith Willis said:
On Tue, 13 Nov 2007 08:49:08 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>>
1) always define main as either:

(a) int main(void)

or:

(b) int main(int argc, char **argv)

Shudder! I am well aware that C != C++, but if one inadvertantly uses
form (a) in "that other froup down the hall", they all start foaming
at the mouth, so because I have to use both languages these days, I
have made something of a point never to use that form :-)
I always use int main(void) for no-args programs, even in C++. Watching C++
programmers foaming at the mouth is good for the soul.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Nov 13 '07 #8
Keith Willis wrote:
On Tue, 13 Nov 2007 08:49:08 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>1) always define main as either:

(a) int main(void)

or:

(b) int main(int argc, char **argv)

Shudder! I am well aware that C != C++, but if one inadvertantly uses
form (a) in "that other froup down the hall", they all start foaming
at the mouth, so because I have to use both languages these days, I
have made something of a point never to use that form :-)
For code which will be compiled as either C or C++ (including many
headers), it is far more desirable to use f(void); because in C++
f(void) is identical semantically to f(), but in C f() has a different
meaning to f(void) and f() will supress a lot of useful compiler warnings.

If you're only writing C++, do what you like. If you're writing which
will be compiled as C, then always use C prototypes.

--
Philip Potter pgp <atdoc.ic.ac.uk
Nov 13 '07 #9
On Nov 13, 8:38 am, "junky_fel...@yahoo.co.in"
<junky_fel...@yahoo.co.inwrote:
First of all, Sorry, for asking the similar and such basic questions
again and again.

The reason why I asked this question is because I was not able to
undertand the following lines (mentioned in n1124.pdf at page 13.

"If the return type of the main function is a type compatible with
int, a return from the
initial call to the main function is equivalent to calling the exit
function with the value
returned by the main function as its argument;10) reaching the } that
terminates the
main function returns a value of 0. If the return type is not
compatible with int, the
termination status returned to the host environment is unspecified."

The wordings are really confusing. Whenever, I read these lines, I
endup in one or other kind of confusion.
Still, the meaning is unclear to me.
The return type of main() is implementation defined. So it
says that if in the implementation you're working with main()
has a return type which is compatible with int then reaching
the end of main() returns the value 0. What "compatible type"
means is defined elsewhere in the standard. On the other hand
if the return type of main() is not compatible with int then
in the absence of an explicit return followed by an expression,
the value returned to the environment is unspecified. The meaning
of "unspecified" is also defined in the standard.

Nov 13 '07 #10
ju**********@yahoo.co.in wrote:
The reason why I had a trouble understanding the lines is due to the
fact that, I was interpreting these lines as follows:

".. a return from the initial call to the main function is equivalent
to calling the exit function with the value
returned by the main function as its argument; reaching the } that
terminates the main function returns a value of 0."

I was interpreting the above as a single line.
http://en.wikipedia.org/wiki/Semicolon
Perhaps, if they would have used "Reaching" instead of "reaching",
And replaced the semicolon with a period (full stop)
it would have been easier for the readers to undertsnat it as follows:
Expecting others to impoverish their writing simply due to ignorance of
punctuation seems a little unfair...

[Note - "ignorance" here is used in a purely descriptive sense. I tend
to favour ignorance over stupidity, as ignorance is curable]
Nov 13 '07 #11
ju**********@yahoo.co.in wrote:
....
The reason why I asked this question is because I was not able to
undertand the following lines (mentioned in n1124.pdf at page 13.

"If the return type of the main function is a type compatible with
int, a return from the
initial call to the main function is equivalent to calling the exit
function with the value
returned by the main function as its argument;
In other words, your program's true start point isn't really main(). The
start-up code performs whatever processing is needed prior to calling
main(), such as setting up the argv array. Then it acts as if it were
compiled from C code that contains either the line

exit(main());

or

exit(main(argc, argv));

or whatever other interfaces to main that it supports.

If you think about it this way, I hope that it's obvious why 'return x;'
is equivalent to 'exit(x);' only in the initial call to main(), and not
in any recursive calls. However, recursive calls to main() are such a
bizarre thing to do that you ordinarily wouldn't have any reason to use
them, particular if you want to compile the same code in C++, where they
are not allowed.
Nov 13 '07 #12
"James Kuyper" <ja*********@verizon.neta écrit dans le message de news:
nHg_i.6165$763.178@trnddc07...
ju**********@yahoo.co.in wrote:
...
>The reason why I asked this question is because I was not able to
undertand the following lines (mentioned in n1124.pdf at page 13.

"If the return type of the main function is a type compatible with
int, a return from the
initial call to the main function is equivalent to calling the exit
function with the value
returned by the main function as its argument;

In other words, your program's true start point isn't really main(). The
start-up code performs whatever processing is needed prior to calling
main(), such as setting up the argv array. Then it acts as if it were
compiled from C code that contains either the line

exit(main());

or

exit(main(argc, argv));

or whatever other interfaces to main that it supports.

If you think about it this way, I hope that it's obvious why 'return x;'
is equivalent to 'exit(x);'
There is a subtle difference: calling exit() from main invokes the functions
registered with atexit with main's local variables still valid. Returning
from main will invoke exit with the return value, but main's local variables
will have been destroyed and any function registered with atexit referencing
them invokes undefined behaviour, that applies to the argc argv arguments
and potentially also to the strings pointed to by the argv array.

--
Chqrlie.
Nov 13 '07 #13
Charlie Gordon wrote:
"James Kuyper" <ja*********@verizon.neta écrit dans le message de news:
....
In other words, your program's true start point isn't really main(). The
start-up code performs whatever processing is needed prior to calling
main(), such as setting up the argv array. Then it acts as if it were
compiled from C code that contains either the line

exit(main());

or

exit(main(argc, argv));

or whatever other interfaces to main that it supports.

If you think about it this way, I hope that it's obvious why 'return x;'
is equivalent to 'exit(x);'
I should have said "roughly equivalent". I was aware of the exception
you describe:
There is a subtle difference: calling exit() from main invokes the functions
registered with atexit with main's local variables still valid. Returning
from main will invoke exit with the return value, but main's local variables
will have been destroyed and any function registered with atexit referencing
them invokes undefined behaviour, that applies to the argc argv arguments
and potentially also to the strings pointed to by the argv array.
In practice, I doubt that this case comes up very often. I didn't want
to complicate my response further by mentioning that exception.

Nov 13 '07 #14
On Wed, 14 Nov 2007 11:22:15 +0000, Spiros Bousbouras wrote:
On Nov 13, 6:53 pm, Keith Thompson <ks...@mib.orgwrote:
>Spiros Bousbouras <spi...@gmail.comwrites:
The return type of main() is implementation defined.

Saying that the return type of main() is implementation defined may be
a little bit misleading. All hosted implementations must support a
return type of int.

We must be reading the beginning of 5.1.2.2.1 differently.
I don't believe you are. Let's say a silly implementation supports
char main(int argc, wchar_t *argv[])
as an extension. It doesn't have to also allow
int main(int argc, wchar_t *argv[])
but since it still must support
int main(int argc, char *argv[])
it does have to support a return type of int. This is consistent with
both your message and Keith's, unless I am the one misreading here.
Nov 14 '07 #15
Keith Willis <m...@privacy.netwrote:
I abandoned the use of void as an argument type
meaning ''no arguments'' after Dennis Ritchie and
Doug McIlroy strongly condemned it as ''an abomination.''
Instead, I adopted the obvious notation for taking no
arguments, an empty pair of parentheses.
For example:
int f (void ); // error: abomination
int g (); // g takes no argument

Does anyone know where they condemnded it ?

Since posting the link to Stroustrup's PDF, I've been
looking for the source of the original comments by
Ritchie and McIlroy, but no luck.
Chances are it was a corridor discussion.

--
Peter
Nov 15 '07 #16
On Tue, 13 Nov 2007 12:15:24 +0000, Mark Bluemel
<ma**********@pobox.comwrote:
>ju**********@yahoo.co.in wrote:
>The reason why I had a trouble understanding the lines is due to the
fact that, I was interpreting these lines as follows:

".. a return from the initial call to the main function is equivalent
to calling the exit function with the value
returned by the main function as its argument; reaching the } that
terminates the main function returns a value of 0."

I was interpreting the above as a single line.

http://en.wikipedia.org/wiki/Semicolon
Perhaps, if they would have used "Reaching" instead of "reaching",

And replaced the semicolon with a period (full stop)
it would have been easier for the readers to undertsnat it as follows:

Expecting others to impoverish their writing simply due to ignorance of
punctuation seems a little unfair...

[Note - "ignorance" here is used in a purely descriptive sense. I tend
to favour ignorance over stupidity, as ignorance is curable]
Considering that it is supposed to be an international standard, it
wouldn't hurt for the writers to consider their readers for whom
English is not the native language. However, since it was written by
committee, clarity was probably not a primary consideration.

In any case, the sentence expresses two completely unrelated, actually
mutually exclusive, concepts. It would hardly impoverish the writing
if they gave each concept its own sentence.
Remove del for email
Nov 15 '07 #17
Spiros Bousbouras wrote:
[...]
How does it follow from the part of the standard that I quoted
that it has to support the two standard forms ? It seems to me
that as long as it satisfies the indented part below the or
meaning the part reading "or in some other implementation-defined
manner" then it can ignore the part above the or. If one of the
two clauses of an or is satisfied then that's good enough , isn't
it ? Although reading the 2nd paragraph of 5.1.2.2.1 perhaps
the intention was that it must always satisfy the part above the
or. If that was the intention then it's not at all clearly phrased.
5.1.2.2.1 specifies requirements for a program, not for an implementation. Note
paragraph 1: "It shall be defined ...". The implementation doesn't define main;
the program does. The implementation's job is to accept any program that meets
the requirements.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 15 '07 #18
Keith Thompson <ks...@mib.orgwrote:
Richard Heathfield <r...@see.sig.invalidwrites:
junky_fel...@yahoo.co.in said:
Can I return 0, from main() ?
Yes.
Is this equivalent to exit(EXIT_SUCCESS) ?
Yes in practice. In theory, EXIT_SUCCESS and 0 both
represent successful termination but the Standard
doesn't forbid them from having different values and
representing different kinds of success! (I don't
know of any implementations that distinguish between
them in this way, and it is likely that there are no
such implementations.)
Perhaps none now, but in the past it was certainly a
possibility on some of the VAX systems.
Obscure exceptions: recursive calls to main() and
atexit()-registered functions that refer to local
variables declared in main().
Perhaps more critical to that scenario is that
EXIT_FAILURE need not have a non-zero value or be
different to EXIT_SUCCESS.

--
Peter
Nov 15 '07 #19
Peter Nilsson wrote:
Keith Thompson <ks...@mib.orgwrote:
>Richard Heathfield <r...@see.sig.invalidwrites:
>>junky_fel...@yahoo.co.in said:
Can I return 0, from main() ?
Yes.

Is this equivalent to exit(EXIT_SUCCESS) ?
Yes in practice. In theory, EXIT_SUCCESS and 0 both
represent successful termination but the Standard
doesn't forbid them from having different values and
representing different kinds of success! (I don't
know of any implementations that distinguish between
them in this way, and it is likely that there are no
such implementations.)

Perhaps none now, but in the past it was certainly a
possibility on some of the VAX systems.
Under VMS (which isn't quite dead, and runs on both VAX and Alpha
hardware, and possibly others), the OS convention is that returning an
even number from a program indicates success, and returning an odd
number indicates failure. This obviously conflicts with the convention
of using exit(0) to indicate success. However, the C runtime works
around this by translating "exit(0)" or "return 0" so that it returns
the value 1 (indicating success) to the environment. It *doesn't* do a
similar translation for "exit(1)".

As I recall (from using VMS about 10 years ago), EXIT_SUCCESS is defined
as 0, and EXIT_FAILURE is defined as some non-zero even number (perhaps
2). So exit(0) and exit(EXIT_SUCCESS) are exactly equivalent, even
under VMS.

This may have been different in the distant past.
>Obscure exceptions: recursive calls to main() and
atexit()-registered functions that refer to local
variables declared in main().

Perhaps more critical to that scenario is that
EXIT_FAILURE need not have a non-zero value or be
different to EXIT_SUCCESS.
True, but if the OS provides a way for a program to indicate success or
failure, it will almost certainly define EXIT_FAILURE as a non-zero
value different from the value of EXIT_SUCCESS. If the OS has no such
mechanism, then the C implementation might as well define both
EXIT_SUCCESS and EXIT_FAILURE as 0 -- but I don't know of any such systems.

Given that both exit(0) and exit(EXIT_SUCCESS) must indicate success (if
that's possible), I can't think of any reason for EXIT_SUCCESS to have a
value other than 0.

In my opinion, requiring exit(0) (or return 0) to denote success was an
over-specification. Traditionally, in Unix, exit(0) indicates success,
and exit(1) indicates a non-specific failure. The C standard broke the
latter, but not the former.

I suppose the rationale was that if there were no guarantees about
exit(0), then any program that wants to terminate normally must have a
"#include <stdlib.h>" so it can use EXIT_SUCCESS.

If C89 hadn't required 0 to denote success, then C99's rule about
falling off the end of main would actually have made sense; it could
have said that reaching the closing "}" is equivalent to returning
EXIT_SUCCESS. But that's not what happened.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 15 '07 #20
Keith Thompson <ks***@mib.orgwrites:
Under VMS (which isn't quite dead, and runs on both VAX and Alpha
hardware, and possibly others), the OS convention is that returning an
even number from a program indicates success, and returning an odd
number indicates failure. This obviously conflicts with the
convention of using exit(0) to indicate success.
0 is an even number.
--
Ben Pfaff
http://benpfaff.org
Nov 15 '07 #21
Ben Pfaff <bl*@cs.stanford.eduwrites:
Keith Thompson <ks***@mib.orgwrites:
>Under VMS (which isn't quite dead, and runs on both VAX and Alpha
hardware, and possibly others), the OS convention is that returning an
even number from a program indicates success, and returning an odd
number indicates failure. This obviously conflicts with the
convention of using exit(0) to indicate success.

0 is an even number.
D'oh!

What I *meant* to say is that returning an even number indicates
failure, and returning an odd number indicates success.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 16 '07 #22
Ben Pfaff wrote:
Keith Thompson <ks***@mib.orgwrites:
>Under VMS (which isn't quite dead, and runs on both VAX and Alpha
hardware, and possibly others), the OS convention is that returning an
even number from a program indicates success, and returning an odd
number indicates failure. This obviously conflicts with the
convention of using exit(0) to indicate success.

0 is an even number.
D'oh!

What I *meant* to say is that returning an even number indicates
failure, and returning an odd number indicates success.

(Sorry if you see this twice; I initially posted through rr.com, which
is under a UDP.)

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 16 '07 #23
"Keith Thompson" <ks***@mib.orga écrit dans le message de news:
fh**********@aioe.org...
Ben Pfaff wrote:
>Keith Thompson <ks***@mib.orgwrites:
>>Under VMS (which isn't quite dead, and runs on both VAX and Alpha
hardware, and possibly others), the OS convention is that returning an
even number from a program indicates success, and returning an odd
number indicates failure. This obviously conflicts with the
convention of using exit(0) to indicate success.

0 is an even number.

D'oh!

What I *meant* to say is that returning an even number indicates
failure, and returning an odd number indicates success.

(Sorry if you see this twice; I initially posted through rr.com, which is
under a UDP.)
I saw it only once ;-)
What is a UDP ?

--
Chqrlie.
Nov 16 '07 #24
Charlie Gordon said:

<snip>
What is a UDP ?
In this context, it stands for "Usenet Death Penalty". It's a sort of mass
plonk, inflicted by news server administrators on an errant peer who is
failing to discipline abusive users.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Nov 16 '07 #25
On Nov 15, 9:03 pm, Keith Thompson <ks...@mib.orgwrote:
Spiros Bousbouras wrote:

[...]
How does it follow from the part of the standard that I quoted
that it has to support the two standard forms ? It seems to me
that as long as it satisfies the indented part below the or
meaning the part reading "or in some other implementation-defined
manner" then it can ignore the part above the or. If one of the
two clauses of an or is satisfied then that's good enough , isn't
it ? Although reading the 2nd paragraph of 5.1.2.2.1 perhaps
the intention was that it must always satisfy the part above the
or. If that was the intention then it's not at all clearly phrased.

5.1.2.2.1 specifies requirements for a program, not for an implementation. Note
paragraph 1: "It shall be defined ...". The implementation doesn't define main;
the program does. The implementation's job is to accept any program that meets
the requirements.
Ok , I see it now.
Nov 16 '07 #26
"ju**********@yahoo.co.in" wrote:
>
Can I return 0, from main() ? Is this equivalent to
exit(EXIT_SUCCESS) ?
Yes.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Nov 17 '07 #27
On Mon, 12 Nov 2007 18:33:41 -0500, CBFalconer wrote:
"ju**********@yahoo.co.in" wrote:
>>
Can I return 0, from main() ? Is this equivalent to
exit(EXIT_SUCCESS) ?

Yes.
No, for multiple reasons, as has been explained in this thread already.
Nov 17 '07 #28

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: cppaddict | last post by:
I'd like to know what goes on under the hood when methods return objects. Eg, I have a simple Point class with two members _x and _y. It's constructor, copy constructor, assignment operator and...
32
by: Mike Machuidel | last post by:
Hi, I'm a game developer programming mostly in C and ASM for about 7 years. Today at work a colleague (a C++ programmer) yelled at me I'm a bad C programmer because I use "return(0);" instead...
8
by: M. Moennigmann | last post by:
Dear all: I would like to write a function that opens a file, reads and stores data into an 2d array, and passes that array back to the caller (=main). The size of the array is not known before...
16
by: G Patel | last post by:
Hi, If I want to call functions that don't return int without declaring them, will there be any harm? I only want to assign the function(return value) to the type that it returns, so I don't...
17
by: jwaixs | last post by:
Hello, I was wondering, what's the difference between exit and return in the main() function? For me they both look the same, or aren't they? And if they aren't, which should I use in which...
20
by: lovecreatesbeauty | last post by:
Hello experts, Is the following code snippet legal? If it is, how can exit() do the keyword return a favor and give a return value to the main function? Can a function call (or only this...
25
by: Christian Christmann | last post by:
Hi, the ANSI-C 99 standard specifies that the main function has "int" as return type. However, there are still lots of people declaring "void" as main return type. Did previous ANSI-C...
46
by: Bill Cunningham | last post by:
I have heard that return -1 is not portable. So what would be the answer to portability in this case? What about exit(0) and exit (-1) or exit (1)? Or would it be best to stick with C's macros,...
11
by: Rahul | last post by:
Hi Everyone, I have seen code in different styles like main(argc,argv) int argc; char **argv; { if(argc != 2) exit(1); else exit(0);
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.