我试图将整个 file.txt 读入一个字符数组。但是有一些问题,请提出建议=]
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]
}