title: C: Using strtok to parse command line inputs
body: <p>For a school assignment, I have to make a Unix shell. One of the features that we have to implement is the ability to execute multiple commands from the same line when they are separated by ';'. I'm trying to use strtok to make this happen but for some reason, it only executes the last command (for instance, "ls ; pwd" only executes pwd). Both commands work fine when used individually, but not together. Here's the code involving strtok</p>
  
  <pre><code>const char* s = ";";
  char* token = strtok(pinput, s);
  
          while( token != NULL ) 
          {
              int argc = get_argc(token);
              char** argv = get_argv(argc, token);
  
              parse(argc, argv);
  
              token = strtok(NULL, s);
          }
      }
  </code></pre>
  
  <p>I've tested get_argc, get_argv, and parse a bunch and they both seem to work fine. Is there anything that I'm doing wrong in my use of strtok? Thanks.</p>