title: Running .exe file by CreateProcess cannot generate .txt file
body: <p>I have a <code>hello.cpp</code> file:</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      cout &lt;&lt; "hello" &lt;&lt; endl;
      ofstream file;
      file.open("codebind.txt");
      file &lt;&lt; "this text is written using C++\n" &lt;&lt; "This is a number: " &lt;&lt; 10;
      file.close();
      return 0;
  }
  </code></pre>
  
  <p>After compiling this file by <code>g++</code> using command prompt: <code>g++ -o output hello.cpp</code>, it generated a <code>output.exe</code> file. Then, I managed to run this <code>output.exe</code> file in another <code>.cpp</code> program called <code>program.cpp</code>using <code>CreateProcess()</code> (<a href="http://codepad.org/0mx7SNgM" rel="nofollow noreferrer">link for code</a>). Unfortunately, when I hit Build, the system did not create any <code>codebind.txt</code> file despite the fact that the <code>exitcode</code> variable in <code>program.cpp</code> had a value of 0 as expected. Then I tried going to Explorer and running <code>hello.exe</code> mannually, it created the <code>codebind.txt</code> file. <br/><b>
  Could someone tell me what's wrong with my <code>program.cpp</code> file and how to create <code>codebind.txt</code> using <code>CreateProcess</code>? Any help will be appreciated!</b></p>