title: Simple C++ File stream
body: <p>I want to read then store the content of a file in an array, but this isn't working:<br /></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main () {
      string content,line,fname;
      cout&lt;&lt;"Execute: ";
      cin&gt;&gt;fname;
      cin.ignore();
      cout&lt;&lt;endl;
      //Doesn't work:
      ifstream myfile(fname);
      if(!myfile.is_open()){
          cout&lt;&lt;"Unable to open file"&lt;&lt;endl; 
      }else{
          while(!myfile.eof()){
              getline(myfile,line);
              //I don't know how to insert the line in the string
          }
          myfile.close();
      }
      cin.get();
  
      return 0;
  }
  </code></pre>