Re: Any exit status without explicitely using return /exit

Discussion in 'C Programming' started by jacob navia, Feb 24, 2010.

  1. jacob navia

    jacob navia Guest

    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.
     
    jacob navia, Feb 24, 2010
    #1
    1. Advertising

  2. 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) <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"
     
    Keith Thompson, Feb 24, 2010
    #2
    1. Advertising

  3. In article <>,
    Keith Thompson <> 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."
     
    Kenny McCormack, Feb 24, 2010
    #3
  4. On 24 Feb, 12:38, (Kenny McCormack) wrote:
    > In article <>,
    > Keith Thompson  <> 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.


    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
     
    Nick Keighley, Feb 24, 2010
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amelyan
    Replies:
    0
    Views:
    390
    Amelyan
    May 24, 2005
  2. Phaedrus

    Explicitely calling Thread.run

    Phaedrus, Jul 5, 2003, in forum: Java
    Replies:
    3
    Views:
    476
    Roedy Green
    Jul 6, 2003
  3. Victor Bazarov

    Calling constructor explicitely

    Victor Bazarov, Feb 23, 2005, in forum: C++
    Replies:
    9
    Views:
    4,484
    Ron Natalie
    Feb 24, 2005
  4. Keith Thompson
    Replies:
    10
    Views:
    709
    Tim Rentsch
    Mar 3, 2010
  5. kaleem
    Replies:
    8
    Views:
    847
    Tad McClellan
    Dec 14, 2006
Loading...

Share This Page