Home linux How does EXECLP work, what is the last argument NULL?

How does EXECLP work, what is the last argument NULL?

Author

Date

Category

I read that this is some kind of pointer, unfortunately I can not understand

Let’s try to read man execlp together:

int execlp (const char * file, const char * arg, ...);

Const Char * Arg parameter and similar entries in Execl functions,
ExeClp, and ExeCle implies the parameters arg0, arg1, …, argn. Everything
Together they describe one or more pointers to lines,
Following NULLs, which are a list of parameters,
Available executable program. The first parameter, by agreement,
must specify the name associated with the file that
To execute The list of parameters must end with NULL.

Pay attention to the last sentence. It means that NULL is used to indicate the end of the list of arguments. This is one of the general mechanisms to say “no longer” when calling functions with an alternative number of arguments.


By the way, do you understand that when you successfully start LS here you will never get here?

printf ("koniec \ n");

Answer 1

The last argument of the EXECLP function – NULL is a sign of the end of the list of arguments. ExeClp Returns 0 if the new application is successfully downloaded, and returns -1.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions