.txt ファイル全体を char 配列にコピーしようとしています。私のコードは機能しますが、空白が除外されます。たとえば、.txt ファイルに「I Like Pie」と表示されていて、それを myArray にコピーした場合、for ループを使用して配列を計算すると、「ILikePie」が得られます。
これが私のコードです
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
int arraysize = 100000;
char myArray[arraysize];
char current_char;
int num_characters = 0;
int i = 0;
ifstream myfile ("FileReadExample.cpp");
if (myfile.is_open())
{
while ( !myfile.eof())
{
myfile >> myArray[i];
i++;
num_characters ++;
}
for (int i = 0; i <= num_characters; i++)
{
cout << myArray[i];
}
system("pause");
}
助言がありますか?:/