title: Passing an array to execvp() from the user's input
body: <p>I'm trying to pass arguments entered by the user to <code>execvp()</code>.</p>
  
  <p>So far I've split up the string. If the user types <code>ls -a</code>, <code>temp</code> is saved as "ls" and "-a" followed by a NULL character. I'm not quite sure how to point to this properly in <code>execvp</code>. In examples I've seen it using <code>execvp(temp[position], temp)</code>. I know the way I'm trying to do it at the moment is wrong, but I'm not sure how to do it properly! At the moment I'm getting a segmentation fault.</p>
  
  <pre><code>int main(int argc, char *argv[]) 
  {
      char line[124];
      int size = 124;
      char *temp = NULL;
  
      while(fgets(line, size, stdin) != NULL ) {
          if (strcmp(line, "exit\n") == 0) {
              exit(EXIT_SUCCESS);
          }
          temp = strtok(line, " ");
          while (temp != NULL) {
              printf("%s\n", temp);
              temp = strtok(NULL, " ");
          }
          execvp(temp, &amp;temp);    
      }
      return EXIT_SUCCESS;
  }
  </code></pre>