For example consider following code:
int main(int argc,char *argv[])
{
int *p,*q;
p = (int *)malloc(sizeof(int)*10);
q = (int *)malloc(sizeof(int)*10);
if (p == 0)
{
printf("ERROR: Out of memory\n");
return 1;
}
if (q == 0)
{
printf("ERROR: Out of memory\n");
exit(0);
}
return 0;
}
What does return 0
, return 1
, exit(0)
do in the above program?
exit(0)
will exit total program and control comes out of loop but what happens in case of return 0
, return 1
, return -1
.