Are char * argv[] arguments in main null terminated?

こ雲淡風輕ζ 提交于 2019-11-28 09:35:33
James McNellis

Yes. The non-null pointers in the argv array point to C strings, which are by definition null terminated.

The C Language Standard simply states that the array members "shall contain pointers to strings" (C99 §5.1.2.2.1/2). A string is "a contiguous sequence of characters terminated by and including the first null character" (C99 §7.1.1/1), that is, they are null terminated by definition.

Further, the array element at argv[argc] is a null pointer, so the array itself is also, in a sense, "null terminated."

Yes, it is always true that the arguments are null terminated strings.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!