About command line arguments of main function

后端 未结 4 1362
暗喜
暗喜 2020-12-19 07:44

It will look like int main(int argc, char *argv[]);. My questions are:

1 How many array items can I add in argv[]?

2 What is MAX si

4条回答
  •  清歌不尽
    2020-12-19 08:37

    It probably depends on the mechanism you are using to start your program. If it is through a shell (bash or whatever) you'd have to look up if it imposes restrictions.

    If you start your program through execv or something similar, they should only be subject to the same restrictions as any array and string, and, as somebody noted, because argc is int for historical reasons, to the limited size of int not of size_t.

提交回复
热议问题