Thursday 14 February 2013

The exit() Functions in C Programming Language



In case of any file input-output error or erroneous command line arguments, it is possible to terminate program execution. This can be done through the exit() function as shown in the following example:

if( argc!= 3)
{
printf("Invalid arguments\n");
exit();
}

An integer may also be passed as a parameter to the exit() function. In UNIX, this value is stored in the environmental variable "$?", and should be in the range 0 - 255.

0 comments:

Post a Comment

Powered by Blogger.