title: ofstream: cannot open the file
body: <p>I face an ofstream problem and the program cannot open the file that I want to write. The minimal, complete and varifiable code is showed as follows:</p>
  
  <pre><code>#include &lt;cstdio&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  int main(){
  
      string root_path = "E:\\160818\\";
      string file_path = root_path + "haar_data.txt";
  
      ofstream haar_file(file_path.c_str());
  
      if(!haar_file) // &lt; -------- File cannot be open
      {
          cout&lt;&lt;"Error opening file for writing\n";
          return 1;
      }
      haar_file.close();
  
      return 0;
  }
  </code></pre>
  
  <p>My compiler is VS2008. The output in the screen is </p>
  
  <blockquote>
    <p>Error opening file for writing.</p>
  </blockquote>
  
  <p>What is the error? I want open this file to write something.</p>