Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 13 of 13
When you say random values do you mean something different than having in my programme exit rand() ; for example ?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575

    When you say random values do you mean something different than having
    in my programme exit rand() ; for example ?

  2. #12
    Linux Newbie
    Join Date
    Oct 2004
    Posts
    158
    On an Intel box whatever value is in the EAX register when main ends will be the return code. It can literally be any 32 bit number.

    It's the same concept as
    Code:
    void foo(void)
    {
        char tmp[24];
        printf("%s\n",tmp);
    }
    The variable tmp is on the stack. Whatever values were there previously are still there because tmp is not initialized. foo() has a fair chance of segfaulting, especially if called at the end of a C program. But you can't predict what will be in there. By predict, I mean tell me in advance what will be there -- BEFORE the first time it runs -- ie., what will show up in tmp.

    Everytime foo() is called from a different place in the C code the value is likely to be different.


    If

    What's in tmp is the result of whatever was there last.

  3. #13
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    On an Intel box whatever value is in the EAX register when main ends will be the return code. It can literally be any 32 bit number.
    But the return value ie what you get from the status variable is an 8
    bit number.Or do you mean something different with return code ?

  4. $spacer_open
    $spacer_close
Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •