title: Converting .docx to .txt in C++
body: <p>Apologies for the duplicated (I think) question, new to C++ and have had a look around but still stuck!</p>
  
  <p>I have found a bash script that takes a .docx file and outputs the plain text. </p>
  
  <pre><code>unzip -p filename.docx word/document.xml | sed -e 's/&lt;[^&gt;]\{1,\}&gt;//g; s/[^[:print:]]\{1,\}//g'
  </code></pre>
  
  <p>This works great over bash.</p>
  
  <p>Then to use this in my code:</p>
  
  <pre><code>FILE *fp = popen("unzip -p filename.docx word/document.xml | sed -e 's/&lt;[^&gt;]\\{1,\\}&gt;//g; s/[^[:print:]]\\{1,\\}//g'", "r");
  char buf[1024];
  
  if (fp == NULL) {
      cout &lt;&lt; "Error";
  }
  
  while (fgets(buf, 1024, fp)) {
      /* do something with buf */
      cout &lt;&lt; buf;
  }
  
  fclose(fp);
  </code></pre>
  
  <p><strong>Nothing is printed as a result of this.</strong></p>
  
  <p>The code works with simple bash commands such as 'ls'</p>
  
  <p>And help would be much appreciated!</p>