Exit?

Novato
07 de Julio del 2004
Para que sirve la palabra reservada exit por que tengo un programa que usa esa palabra bastantes veces pero ademas obtiene valores diferentes como iguales a cero y diferentes de cero como:

exit(0);

exit(1);

Para que sirve exit y por que adquiere esos valores?

Mariano Ventaja
07 de Julio del 2004
En general terminan el programa y devuelven el valor pasado por parámetro.

The exit and _exit functions terminate the calling process. exit calls, in last-in-first-out (LIFO) order, the functions registered by atexit and _onexit, then flushes all file buffers before terminating the process. _exit terminates the process without processing atexit or _onexit or flushing stream buffers. The status value is typically set to 0 to indicate a normal exit and set to some other value to indicate an error.

Si usas VC++:
Although the exit and _exit calls do not return a value, the low-order byte of status is made available to the waiting calling process, if one exists, after the calling process exits. The status value is available to the operating-system batch command ERRORLEVEL and is represented by one of two constants: EXIT_SUCCESS, which represents a value of 0, or EXIT_FAILURE, which represents a value of 1. The behavior of exit, _exit, _cexit, and _c_exit is as follows.

Saludos,
Mariano http://www.c0d3rz.com.ar