Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>execlp() execute program using argument list and path</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 execlp()                Execute Program Using Argument List and Path

 #include   <process.h>

 int        execlp(pathname, arg0,arg1,...,argn,NULL);

 char       *pathname;                   Path name of file to be executed
 char       *arg0,*arg1,...,*argn;       List of pointers to arguments

    execlp() operates identically to execl(), with one exception:  If
    'pathname' is not found as described in execl(), then execlp() will
    use the DOS PATH to continue the search for the path name.  With that
    single exception, the two functions are identical; see execl() for a
    complete description.

   -------------------------------- Example ---------------------------------

    The following statements transfer execution to the child process
    "child", and pass it the three arguments "CHILD", "arg1", and "arg2".
    "child", "child.com", or "child.exe" can be in the current directory,
    or any PATH directory:

           #include <process.h>    /* for 'execlp' */
           #include <stdio.h>      /* for 'printf' and 'NULL' */
           #include <errno.h>      /* for 'errno, 'ENOENT' and 'ENOMEM' */

           main()
           {
               execlp("child", "CHILD", "arg1", "arg2", NULL);
               /* only get here on an exec error */
               if (errno == ENOENT) {
                   printf("neither child nor child.exe found in current\n");
                   printf("  directory, or in any PATH directory\n");
               }
               else if (errno == ENOMEM)
                   printf("not enough memory to execute child\n");
               else
                   printf("error #%d trying to exec child\n", errno);
           }


See Also: execl() execlpe() spawnlpe() execvp() exec...()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson