Can argc be zero on a POSIX system?

前端 未结 6 1397
暖寄归人
暖寄归人 2021-02-04 23:04

Given the standard definition for the main program:

int main(int argc, char *argv[]) {
   ...
}

Under which circumstances can argc

6条回答
  •  星月不相逢
    2021-02-04 23:34

    To add to the other answers, there is nothing in C (POSIX or not) preventing main() from being called as a function within the program.

    int main(int argc, int argv[]) {
        if (argc == 0) printf("Hey!\n");
        else main(0,NULL);
    
        return 0;
    }
    

提交回复
热议问题