Why does argv terminate with a null pointer?

The execve () man page says argv is a list of string arguments that ends with a null pointer. But why do we need NP? I mean, the number of arguments is stored in argc, so what's the point of the null pointer?

+3
source share
2 answers

execvedoes not accept argcas a parameter, it manually counts the arguments that you give as argv, to determine itself argc.

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

+6
source

The counter for is argccalculated by searching for this NULL.

+5
source

Source: https://habr.com/ru/post/1733817/


All Articles