title: execv() quirks concerning arguments
body: <p>I'm trying to output the results of 'ps' for an assignment, but I've ran into some slight quirks that I'd like to figure out.</p>
  
  <p>This works correctly, and displays ps's output in the shell:</p>
  
  <pre><code>//Create "ps -u laser"
  int pid_ps = fork();
  char *argv[1] = {"-u laser"};
  if (pid_ps == 0) {
     execv("/bin/ps", argv);
  }
  </code></pre>
  
  <p>Now, this is the format that was given in my slides, but just gives the "usage:" and "format is one or more of:" notifications for ps when it's run:</p>
  
  <pre><code>//Create "ps -u laser"
  int pid_ps = fork();
  char *argv[2] = {"-u", "laser"};
  if (pid_ps == 0) {
     execv("/bin/ps", argv);
  }
  </code></pre>
  
  <p>I also tried putting 0 and NULL on the end of the array, which was suggested in other answers, but no luck.</p>
  
  <p>I'm probably overlooking something minor, but I'm not too familiar with c. Any insight is appreciated.</p>