[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


exit

Terminate a program normally.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stdlib.h>
void exit(int status);
Parameters:

Parameters for this facility are:

status  
int  
The exit error value  

Remarks:

The exit() function calls every function installed with atexit() in the reverse order of their installation, flushes the buffers and closes all open streams, then calls the Toolbox system call ExitToShell().

Return:

exit() does not return any value to the operating system. The status argument is kept to conform to the ANSI C Standard Library specification.

See Also:

"abort"

"atexit"

Example of exit() usage.:
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	FILE *f;
	int count;
	
	// create a new file for output exit on failure
	if (( f = fopen("foofoo", "w")) == NULL) { 
		printf("Can't create file.\n");
		exit(1);
	}

	// output numbers 0 to 9
	for (count = 0; count < 10; count++)
		fprintf(f, "%5d", count);

	// close the file
	fclose(f);

	return 0;
}


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000