title: CMD.exe quoting a string
body: <p>What's the exact way to <em>properly</em> quote a single command line argument?
  For example, I have some random text in a variable <code>$X</code>. I need to quote it in a way so that if I call</p>
  
  <pre><code>system("program.exe " + $X_QUOTED);
  </code></pre>
  
  <p>then <code>argv[1]</code> of my program.exe has to match original unquoted <code>$X</code></p>
  
  <p>imagine I have this program.exe:</p>
  
  <pre><code>int main(const char **argv, int){ puts(argv[1]); }
  </code></pre>
  
  <p>and the output of command: "program xxxx" is:</p>
  
  <pre><code>"test |test
  </code></pre>
  
  <p>what <code>xxxx</code> has to literally be? I tried to add quotes and all that trickery, but then I can always add some other type of output that would break my approach to quote cmd line arguments.</p>