Why do we need argc while there is always a null at the end of argv?

前端 未结 4 636
离开以前
离开以前 2020-12-08 03:41

It seems that the argv[argc] is always NULL, so I think we can traverse the argument list without argc. A single while lo

4条回答
  •  Happy的楠姐
    2020-12-08 04:14

    It's for historical reasons, and compatibility with old code. Originally, there was not a guarantee that there would exist a null pointer as the last element of the argv array. But argc has always existed.

提交回复
热议问题