title: ofstream with a custom name and path
body: <p>I want to make a bat file that are stored in a specific folder (<code>string path = "C:\Users\"</code>) with a name that are given by user and saved in string. How to do it?</p>
  
  <p>I saw something like this on another questions:<code>(path\\filename)</code>, but in my case, the name is a string, so i don't know how to make it.</p>
  
  <pre><code>void BatFile()
  {
      std::string filename, username;
      std::cout &lt;&lt; "Name your save file in database:\n\n"; std::cin &gt;&gt; filename;
      filename = filename + ".bat";
      std::ofstream batout(filename);
      std::cout &lt;&lt; "Username="; std::cin &gt;&gt; username;
      batout.open(filename);
      batout &lt;&lt;""; //write to bat file.
      batout.close();
  }
  </code></pre>
  
  <p>I put the path in string because i don't know if i will not make to choose the user the directory where he will want to save that bat files what will be made.</p>