On my desktop I have .txt file. I need to read all bytes from memory to array.
I tried to read text from file to string and then using memcpy() read bytes from string but I think this is not correct.
Tnx.
ifstream File("C:\\Users\\Flone\\Desktop\\ass.txt");
string file_text;
//start to read TEXT file (look end below):
char word_buffer[30];
for (int i = 0; i < 30; i++)
{
word_buffer[i] = NULL;
}
while (File.eof() == false)
{
File >> word_buffer;
for (int i = 0; i < 30; i++)
{
if (word_buffer[i] != NULL)
{
file_text += word_buffer[i];
}
}
if (File.eof()==false) file_text += " ";
for (int i = 0; i < 30; i++)
{
word_buffer[i] = NULL;
}
}
File.close();
//end read TEXT file.
cout << file_text << endl;
It works but I'm reading bytes from my string and not file or is it the same?