Read text file into char Array. C++ ifstream

Im trying to read the whole file.txt into a char array. But having some issues, suggestions please =]

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 << getdata << endl;
}

 //but this outputs the last half of the file + trash
 for (int i=0; i<10000; i++){
   cout << getdata[i]
 }
6
задан nubme 7 December 2010 в 03:10
поделиться