title: Read text file into char Array. C++ ifstream
body: <p>Im trying to read the whole file.txt into a char array. But having some issues, suggestions please =]</p>
  
  <pre><code>ifstream infile;
  infile.open("file.txt");
  
  char getdata[10000]
  while (!infile.eof()){
    infile.getline(getdata,sizeof(infile));
    // if i cout here it looks fine
    //cout &lt;&lt; getdata &lt;&lt; endl;
  }
  
   //but this outputs the last half of the file + trash
   for (int i=0; i&lt;10000; i++){
     cout &lt;&lt; getdata[i]
   }
  </code></pre>