title: C - Separate a string by quotations then spaces
body: <p>I want to separate a char* variable into a char** array by first the quotations then by spaces.</p>
  <p>For instance,</p>
  <pre><code>char* str = &quot;\&quot;I am in quotes\&quot; and I am not, however \&quot; I am \&quot;&quot;;
  char* strCopy = malloc(strlen(str)+1)
  strcpy(strCopy, str);
  
  char** args = get_args(strCopy);
  
  int i = 0;
  while(args[i]) {
      printf(&quot;%s\n&quot;, args[i]);
      i++;
  }
  </code></pre>
  <p>Would produce the output:</p>
  <pre><code>I am in quotes
  and 
  I
  am
  not,
  however
  I am
  </code></pre>
  <p>Part of the trouble is I also want to account for if the quotations are not closed, e.g.</p>
  <pre><code>char* str  = &quot;\&quot;My quotes are closed \&quot; but \&quot;mine are not&quot;;
  </code></pre>
  <pre><code>My quotes are closed
  but
  &quot;mine
  are
  not
  </code></pre>
  <p>I have attempted to use strtok, but I can't seem to get it to work this way.</p>