salehvasaleh
Member
اگر بخوایم انتهای یه تابع کلی، تابعی رو بنویسیم که با انتخاب اون (مثلا انتخاب اون از طریق دستور سویش) بشه از کل تابع خارج بشیم باید چیکار کنیم؟ بطور کلی یعنی طرز نوشتن تابعی برای خروج در زبان سی چطوریه؟
#include<stdio.h>
#include<conio.h>
#include<process.h>
void record();
/****************************************************************************************************/
void main()
{
clrscr();
printf("in the main");
record();
printf("\nin the main\tafter function call");
printf("\npress any key for exit");
getch();
}
/******************************************************************************************************/
void record()
{
printf("\nin the record_function\npress any key for exit");
getch();
exit(0);
}
exit terminates the program
þ _cexit performs exit cleanup without terminating the program
Declaration:
þ void exit(int status);
þ void _cexit(void);
Remarks:
exit terminates the calling process. Before termination, exit does the
following:
þ closes all files
þ writes buffered output (waiting to be output)
þ calls any registered "exit functions" (posted with atexit)
_cexit performs the same cleanup as exit, except that it does not close
files or terminate the calling process.
_cexit restores interrupt vectors altered by the startup code.
status
ßßßßßß
With exit, status is provided for the calling process as the exit status of
the process.
Typically a value of 0 indicates a normal exit, and a non-zero value
indicates some error.
You use the following to set status:
status ³ Indicates
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
EXIT_SUCCESS ³ Normal program termination
EXIT_FAILURE ³ Abnormal program termination. Signal to operating
³ system that program has terminated with an error.
Return Value: None
Portability:
É DOS Ñ UNIX Ñ ANSI C Ñ C++ Only »
_cexit º Yes ³ ³ ³ º
exit º Yes ³ Yes ³ Yes ³ º
ÈÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍͼ