سلام!
کد:
void exit ( int status );
Status value returned to the parent process. Generally, a return value of 0 or EXIT_SUCCESS indicates success, and any other value or the constant EXIT_FAILURE is used to indicate an error or some kind of abnormal program termination.
مقدار status که پارامتر ورودی تابع هست بر می گرده به Process والد. مقدار برگشتی 0 یا EXIT_SUCCESS حاکی از موفقیته و هر مقدار برگشتی دیگری یا EXIT_FAILURE استفاده می شه برای این که بگه Error ای رخ داده یا برنامه به طور غیر طبیعی پایان یافته.
مثال:
کد:
/* exit example */
#include <stdio.h>
#include <stdlib.h>
int main ()
{
FILE * pFile;
pFile = fopen ("myfile.txt","r");
if (pFile==NULL)
{
printf ("Error opening file");
exit (1);
}
else
{
/* file operations here */
}
return 0;
}