Difference between return 1, return 0, return -1 and exit?

后端 未结 6 472
终归单人心
终归单人心 2020-12-22 22:17

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)*1         


        
6条回答
  •  醉酒成梦
    2020-12-22 22:54

    To indicate execution status.

    status 0 means the program succeeded.

    status different from 0 means the program exited due to error or anomaly.

    return n; from your main entry function will terminate your process and report to the parent process (the one that executed your process) the result of your process. 0 means SUCCESS. Other codes usually indicates a failure and its meaning.

提交回复
热议问题