全体の.txtファイルをchar配列にコピーしようとしています。 私のコードは動作しますが、開くファイルの最後の行だけを取得します。ここ は私のコードで、大きな感謝全体の.txtファイルをC++のchar配列にコピー
#include <fstream>
using namespace std;
std::ifstream fileToRead;
unsigned char array[512];
fileToRead.open("test.txt");
if(fileToRead.is_open()){
while(!fileToRead.eof()){
fileToRead >> array;
}
fileToRead.close();
}
printf("%s\n", array);
@piyushiそれは私にはうまくいかない、ありがとう –
何があなたのためには機能しないのですか? – piyushj
[こちら](http://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-considered-wrong)を読んでください。 –