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?
+5
A:
The count for argc
is calculated by looking for this NULL.
Ignacio Vazquez-Abrams
2010-02-22 00:42:23
+6
A:
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.
SoapBox
2010-02-22 00:43:56
Oh, sry, now I see it. Now that makes perfect sense.
Helper Method
2010-02-22 00:57:06