为什么 argv 以空指针结束?
在 execve() 手册页中,据说 argv 是一个以空指针结尾的字符串参数列表。但是NP有什么用呢?我的意思是,参数的数量存储在 argc 中,那么空指针有什么意义呢?
In the execve() man page it is said that argv is a list of string arguments which is ended by a null pointer. But what is the NP for? I mean, the number of arguments is stored in argc, so what's the point of the null pointer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
execve
不将argc
作为参数,它手动计算您提供的argv
参数来确定argc
本身。这是为了与
execl
兼容,它采用可变数量的参数而不是argv
数组。execve
does not takeargc
as a parameter, it manually counts the arguments you give asargv
to determineargc
itself.This is for compatibility with
execl
which takes a variable number of arguments instead of anargv
array.argc 的计数是通过查找该 NULL 来计算的。
The count for
argc
is calculated by looking for this NULL.