为什么 argv 以空指针结束?

发布于 2024-08-22 13:28:21 字数 93 浏览 5 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心凉 2024-08-29 13:28:21

execve 不将 argc 作为参数,它手动计算您提供的 argv 参数来确定 argc 本身。

这是为了与 execl 兼容,它采用可变数量的参数而不是 argv 数组。

execve does not take argc as a parameter, it manually counts the arguments you give as argv to determine argc itself.

This is for compatibility with execl which takes a variable number of arguments instead of an argv array.

や三分注定 2024-08-29 13:28:21

argc 的计数是通过查找该 NULL 来计算的。

The count for argc is calculated by looking for this NULL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文