Im trying to copy a whole .txt file into a char array. My code works but it retrieves just the last line in the file to be opened. Here is my code, and a big thanks
#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);