title: C++ Creating a File if it does not exist
body: <p>I am wanting to create a file in a  folder using OFstream.   The following lines of code - always Give "Output File could not be created...". No matter what I try.</p>
  
  <p>Eventually I want to replace the JOHN part of the string, with a variable (type String).</p>
  
  <p>Tips would be very much appreciated. </p>
  
  <pre><code>     ofstream output_file(".\\Players\\JOHN\\Balance.txt", ios::app); // open the output file for appending
  if (!output_file.is_open()) { // check for successful opening
      cout &lt;&lt; "Output file could not be opened! Terminating!" &lt;&lt; endl;
      _sleep(1000);
      return 1; 
  }
  else{
  
  output_file &lt;&lt; getAcctbal(); 
  output_file.close();
  return 0;
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>What have is a Players Folder - in that Players folder. for each individual Player I want to  have a file (so John) is a Folder in this case. This folder doesn't exist, and is something I am trying to achieve.
  Thank you very much :-)</p>