title: C/C++ Pointers and Arrays help
body: <p>I have the following C++ code and I can't seem to get it working. What I am trying to do is read numerous entries from the command line, separated by ('|') pipe characters, and then splitting the resulting strings by spaces.   </p>
  
  <pre><code>eg. 
  
  mkdir C:/unixcode/shells|cd D:/margins/code | pwd| finger kobojunkie | last -l kobojunkie
  </code></pre>
  
  <p>but so far, I get errors, something about declaring the size of the pointer:</p>
  
  <blockquote>
    <p>Initializer fails to determine the size of <code>argv2</code>
    cannot convert <code>char**</code> to <code>char*</code> for argument 1 to <code>char strtok(char*, const char*)</code></p>
  </blockquote>
  
  <pre><code>int main(int argc, char *argv[])
  {
      char * pch;
      pch = strtok (argv,"|");
      //parse the contents of the generated arrays
      while (pch != NULL)
      {
          printf ("%s\n",pch);
          char * argv2[] = pch;
          char * subpch = strtok(argv2," ");
  
          while (subpch !=NULL)
          {
              printf ("%s\n",subpch);
              subpch = strtok (NULL, " ");
          }
          pch = strtok (NULL, " ");
      }
      return 0;
  }
  </code></pre>