title: C: fgets() and command line input
body: <p>I'm trying to write a program that handles processes.
  The user will be prompted..</p>
  
  <pre><code>shell: start emacs file.c
  Process 346 has started.
  </code></pre>
  
  <p>I'm having a few issues with fgets, since I don't know what to put as my third argument (I want it to take in from the command line/argv) with</p>
  
  <p><strong>fgets(buffer, 4096,</strong> How can I do a file pointer if I'm not doing a file, <strong>just argv?)</strong></p>
  
  <pre><code>int main(int argc, char **argv)   
  {
   while(1) {
      printf("shell: ");   
  int status, pid;
  int i=0;
  char buffer[4097];
      fgets(buffer, 4096, ???? ) //I want it to take in from argv. Do I need to declare 4096?
  
  if(strcmp(argv[1],"start") == 0 )
      { printf("myshell: process has started \n");
             while (str = strtok(buffer," ") = NULL)  //??? What do I declare str as?
              argv[i] = str;    
              i = i+1;
              }      
  
              if ((pid = fork()) &lt; 0) {  //Child process fork
              perror("fork");       
              exit(1);
              }
              if (pid == 0) {  //Child executes code
              execvp(argv[0], argv );
              perror(argv[1]);    //argv1? 
              exit(1);
               }
      }
  </code></pre>
  
  <p>Does this make sense fort the desired behavior explained above? I'm not entirely sure of the location of my while loop that has strtok, didn't know if that maybe has to be outside of the if-statement. </p>
  
  <p>Also, is it correct for my strtok function to be called as strtok(buffer, " ")? Thank you.</p>