Thread: simple frontend program problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    > I don't use TAB because Vim already does it for me.....
    Then set it to use 4 spaces, not one TAB character.
    Whether you physically press the tab key is irrelevant, there are tab chars in your code, and it looks a mess posted here.

    > I think arg_list[0] = "mpg321" is ok as long as this pointer does not deal with NULL.
    Wrong - you can only delete what you got with new
    Since "mpg321" isn't from new, then delete will likely barf all over you.

    I suggest you use opendir() readdir() closedir() for getting directory listings.

    Hard to say what is wrong with your two examples, since neither compiles, and its too short to guess the context in which they're being used.
    In any event, you should really specify the full path to the name of the program being run "/bin/ls" instead of just "ls"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  2. #2
    Registered User gandalf_bar's Avatar
    Join Date
    Oct 2003
    Posts
    92
    >In any event, you should really specify the full path to the name of the program being >run "/bin/ls" instead of just "ls"

    I learn about system call from http://www.advancedlinuxprogramming.com . Here's why I choose not to specify the full path of the program.


    .....................
    The exec functions replace the program running in a process with another program.
    When a program calls an exec function, that process immediately ceases executing that
    program and begins executing a new program from the beginning, assuming that the
    exec call doesn't encounter an error.
    Within the exec family, there are functions that vary slightly in their capabilities
    and how they are called.


    1 Functions that contain the letter p in their names (execvp and execlp) accept a
    program name and search for a program by that name in the current execution
    path; functions that don't contain the p must be given the full path of the pro-
    gram to be executed.


    2 Functions that contain the letter v in their names (execv, execvp, and execve)
    accept the argument list for the new program as a NULL-terminated array of
    pointers to strings. Functions that contain the letter l (execl, execlp, and
    execle) accept the argument list using the C language's varargs mechanism.
    3 Functions that contain the letter e in their names (execve and execle) accept an
    additional argument, an array of environment variables.The argument should be
    a NULL-terminated array of pointers to character strings. Each character string
    should be of the form "VARIABLE=value".
    Because exec replaces the calling program with another one, it never returns unless an
    error occurs.
    The argument list passed to the program is analogous to the command-line argu-
    ments that you specify to a program when you run it from the shell.They are available
    hrough the argc and argv parameters to main. Remember, when a program is
    nvoked from the shell, the shell sets the first element of the argument list argv[0]) to
    he name of the program, the second element of the argument list (argv[1]) to the
    irst command-line argument, and so on.When you use an exec function in your pro-
    grams, you, too, should pass the name of the function as the first element of the argu-
    ment list.
    ......................


    What do you think about that? It said if I use execvp that use 'p' character, I don't need to specify the full path of the program I use.

    Beside that I accept your suggestion fully.
    A man asked, "Who are you?"
    Buddha answered, "I am awaked."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Running Program Problem
    By warfang in forum C++ Programming
    Replies: 10
    Last Post: 03-28-2007, 02:02 PM
  2. simple login program problem
    By suckss in forum C Programming
    Replies: 11
    Last Post: 11-11-2006, 05:02 PM
  3. Problem with a simple program
    By Salgat in forum C Programming
    Replies: 10
    Last Post: 06-15-2006, 05:57 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM