Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Any exit status without explicitely using return /exit

Reply
Thread Tools

Re: Any exit status without explicitely using return /exit

 
 
jacob navia
Guest
Posts: n/a
 
      02-24-2010
Debanjan a écrit :
> This actually bugging me from quite sometime now.The question is like
> this : How to set the the exit status of a program to any value
> without explicitly using return/exit in gcc ?
>
> Let us consider this piece of code : (Takes input from stdin and print
> it to the stdout until a zero input 0 is encountered)
>
> #include <stdio.h>
>
> int main(){
> int n;
> while(scanf("%d",&n) && n>0 )
> printf("%d\n",n);
> }
>
> In my system (which is windows + mingw) it is returning 1,How to make
> it to return 0 or anything else implicitly without explicitly using
> exit/return ?



Standard C guarantees a return of zero for a main() function that
doesn't explicitly assign a return value.
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      02-24-2010
jacob navia <> writes:
[...]
> Standard C guarantees a return of zero for a main() function that
> doesn't explicitly assign a return value.


By "Standard C", of course, jacob means C99. In C90, which jacob
insists on ignoring, the exit status of such a program is undefined.
(Yes, C99 superseded C90. Yes, C99 is the one and only official
C standard. We know, jacob, we know.)

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
 
Kenny McCormack
Guest
Posts: n/a
 
      02-24-2010
In article <>,
Keith Thompson <kst-> wrote:
>jacob navia <> writes:
>[...]
>> Standard C guarantees a return of zero for a main() function that
>> doesn't explicitly assign a return value.

>
>By "Standard C", of course, jacob means C99. In C90, which jacob
>insists on ignoring, the exit status of such a program is undefined.
>(Yes, C99 superseded C90. Yes, C99 is the one and only official
>C standard. We know, jacob, we know.)


This last paragraph is very illustrative of the CLC attitude.
Which is "When you say something lacking in precision in any way, we are
only too eager to point it out, repeatedly, and to pile on to our hearts
content. But when we say something a little sloppy, it's OK because we
run this place. And, further, it is you who are, again, at fault, for
pointing out our lack of precision."

 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      02-24-2010
On 24 Feb, 12:38, gaze...@shell.xmission.com (Kenny McCormack) wrote:
> In article <ln3a0r2eqd....@nuthaus.mib.org>,
> Keith Thompson *<ks...@mib.org> wrote:
> >jacob navia <ja...@spamsink.net> writes:


> >> Standard C guarantees a return of zero for a main() function that
> >> doesn't explicitly assign a return value.

>
> >By "Standard C", of course, jacob means C99. *In C90, which jacob
> >insists on ignoring, the exit status of such a program is undefined.
> >(Yes, C99 superseded C90. *Yes, C99 is the one and only official
> >C standard. *We know, jacob, we know.)

>
> This last paragraph is very illustrative of the CLC attitude.


no. there is no clc attitude

> Which is "When you say something lacking in precision in any way,


I don't think jacob was lacking in precision. I think he said exactly
what he meant to say. It's hard to imagine he missed mentioning C89 by
mistake as he is currently posting to two different threads arguing
there is some sort of conspiracy to premote C89 and denigrate C99.

> we are
> only too eager to point it out, repeatedly, and to pile on to our hearts
> content. *But when we say something a little sloppy, it's OK because we
> run this place. *And, further, it is you who are, again, at fault, for
> pointing out our lack of precision."


normally I ignore kenny but he needs refuting from time to time just
in case anyone was taking him seriously
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Any exit status without explicitely using return /exit Keith Thompson C Programming 10 03-03-2010 12:41 AM
In a Perl script 'exit 1' returns exit status 0! kaleem Perl Misc 8 12-14-2006 12:52 AM
Must explicitely the ID of control? Why? Amelyan ASP .Net 0 05-23-2005 11:50 PM
What's the difference of return 0; exit(0);exit(1) QQ C Programming 5 05-10-2005 10:11 PM
os.popen varies return type depending on exit status? David M. Wilson Python 1 03-05-2004 07:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57