title: Is my fstream bad or not good()?
body: <p>So I have a .cpp file with a Function which recieves a filename, and should return a String with the contents of the file (actualy modified contents, I modified the code to make it more understandable, but that doesn't have any effect on my problem). The problem is that <code>f.good()</code> is returning <code>false</code> and the loop, which reads the file is not working.
  CODE : </p>
  
  <pre><code>#include "StdAfx.h"
  #include "Form21.h"
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  
  
  
      string ReadAndWrite(char* a){
      char filename[8];
      strcpy_s(filename,a);
      string output;
      char c;
      ifstream f(filename,ios::in);
      output+= "Example text"; // &lt;-- this writes and returns just fine!
      c = f.get();
  
      while (f.good())
        { 
  
      output+= c;
      c= f.get();         
            }
  
      return output;
  }
  </code></pre>
  
  <p>Does anyone have an idea on why this is happening?
  Does it have something to do with, that this is a seperate .cpp file( it doesnt even throw out an error when I remove <code>#include &lt;fstream&gt;</code>).
  Maybe there is a different kind of method to make the loop?
  I'll be very happy to hear any suggestions on how to fix this <em>or</em> maybe a different method on how to achieve my goal.</p>