Im trying to copy a whole .txt file into a char array. My code works but it leaves out the white spaces. So for example if my .txt file reads "I Like Pie" and i copy it to myArray, if i cout my array using a for loop i get "ILikePie"
Here is my code
#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");
}
any suggestions? :/