Exit the calling program
#include <stdlib.h> void exit( int status );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The exit() function causes the calling program to exit normally. When a program exits normally:
The exit() function doesn't return.
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char *argv[] )
{
    FILE *fp;
    if( argc <= 1 ) {
        fprintf( stderr, "Missing argument\n" );
        exit( EXIT_FAILURE );
    }
    fp = fopen( argv[1], "r" );
    if( fp == NULL ) {
        fprintf( stderr, "Unable to open '%s'\n", argv[1] );
        exit( EXIT_FAILURE );
    }
    fclose( fp );
    exit( EXIT_SUCCESS );
    
    /*
     You'll never get here; this prevents compiler
     warnings about "function has no return value".
    */
    return EXIT_SUCCESS;
}
| Safety: | |
|---|---|
| Cancellation point | No | 
| Interrupt handler | No | 
| Signal handler | No | 
| Thread | Yes |