On Fri, 5 Mar 1999 [EMAIL PROTECTED] wrote:

# I've seen a lot of source code lately. My idea the best way to learn a
# language ...
# 
# I've noticed that exit() can take a parameter. I've seen exit(0), exit(1),
# exit(2) and even exit(10). What does the parameter mean ? I can't find any
# table with its possible values ...

the number is known as an exit status and is returned to the parent of that
process (which if you run the program from a shell then the exit status is
returned to the shell).

there are no specific numbers, you can put whatever you like there. There
are a few conventions however...

0 - Normal termination
1 - abnormal termination (something bad happened and you had some sort of
        error routine that called exit(1))

e.g

int main ()
{
        int fd;

        if (!fd = open (.......))
        {
                perror ("open");
                exit (1);
        }

        ... rest of normal code ...

        exit (0);
}

-- 
+++           Beware of programmers who carry screwdrivers           +++
[EMAIL PROTECTED]     http://www.users.globalnet.co.uk/~kermit

Reply via email to