When run a c++ exe in a python code, don't change text file
<p>I have a c++ code that in this, i change strings in a text file.
this code run correctly. but when i run exe of this code in a python file, run correctly but don't change strings of text file.
what must i do?</p>

<p>part of my c++ for change text file:</p>

<pre><code>ofstream myfile;
 myfile.open ("example.txt");
myfile &lt;&lt; i &lt;&lt; endl;
 myfile.close();
</code></pre>

<p>and i run exe of this code in python with this part of code:</p>

<pre><code>os.system(mycppcode)
</code></pre>

<p>The problem here is that your compiled cpp binary runs in a wrong directory (check your user directory for <code>example.txt</code>)</p>

<p>You need to specify full path to your executable in python script:</p>

<pre><code>os.system(os.getcwd() + '/test')
</code></pre>

python c++ text exe