Hi Everyone, I'm a noob a programming and I've been desperately trying to read a single byte of a file in binary. But whenever I look online all I can find is.
I get that and how it can be used with write() to copy a file, but what I need is to read the value of a, specific byte and maybe copy it to an array or int. How do I do that?Code:#include <iostream> #include <fstream> using namespace std; ifstream::pos_type size; char * memblock; int main () { ifstream file ("example.bin", ios::in|ios::binary|ios::ate); if (file.is_open()) { size = file.tellg(); memblock = new char [size]; file.seekg (0, ios::beg); file.read (memblock, size); file.close(); cout << "the complete file content is in memory"; delete[] memblock; } else cout << "Unable to open file"; return 0; }
Please help.



LinkBack URL
About LinkBacks


