title: How to save data, user specified
body: <p>this is a programme that needs to save the outputs to a user specified data file however it doesn't seem to save and Im not sure why, Im relatively new to C++ so any help is appreciated</p>
  
  <pre><code>cout &lt;&lt; "Press 's' then 'Enter' to save the file or any other key then 'Enter' to display";
  cin &gt;&gt; save;
  
  if (save != 's')
  {
      cout &lt;&lt; "Ix = " &lt;&lt; Ix &lt;&lt; "A\n";
      cout &lt;&lt; "Iy = " &lt;&lt; Iy &lt;&lt; "A\n";
      cout &lt;&lt; "Vz = " &lt;&lt; Vz &lt;&lt; "V\n";
  }
  else
  {
      cout &lt;&lt; "Please enter a name for your file: \n";
      cin &gt;&gt; filename;
  
      cout &lt;&lt; " Please enter a directory to save your file in: \n";
      cin &gt;&gt; filepath;
  
      ofstream file((filepath + "/" + filename).c_str());
  
  //input is being writen to the file
      file &lt;&lt; "Ix = " &lt;&lt; Ix &lt;&lt; "A\n";
      file &lt;&lt; "Iy = " &lt;&lt; Iy &lt;&lt; "A\n";
      file &lt;&lt; "Vz = " &lt;&lt; Vz &lt;&lt; "V\n";
  
      file &lt;&lt; flush;
      file.close();
  }
  </code></pre>
  
  <p>}</p>