title: Parsing a string in c++ with a specfic format
body: <p>I have this string <code>post &quot;ola tudo bem como esta&quot; alghero.jpg</code> and i want to break it into 3 pieces <code>post</code>, <code>ola tudo bem como esta</code> (i dont want the &quot;&quot;) and <code>alghero.jpg</code> i tried it in c because im new and not really good at programming in c++ but its not working. Is there a more efficient way of doing this in c++?</p>
  <p>Program:</p>
  <pre><code>int main()
  {
      char* token1 = new char[128];
      char* token2 = new char[128];
      char* token3 = new char[128];
      char str[] = &quot;post \&quot;ola tudo bem como esta\&quot; alghero.jpg&quot;;
      char *token;
     
      /* get the first token */
      token = strtok(str, &quot; &quot;);
      //walk through other tokens
      while( token != NULL ) {
          printf( &quot; %s\n&quot;, token );
          
          token = strtok(NULL, &quot; &quot;);
      }
      return(0);
  }
  </code></pre>