How is data stored when read in using fstream class? An example will clarify my question:
char * memBlock = NULL;
fileSize = file.tellg();
memBlock = **new** char[fileSize];
file.seekg(0, ios::beg);
file.read(memBlock, fileSize);
file.close();
if(memBlock)
return memBlock;
The context is that I am reading a raw image that has been recorded in hex so that
- the values representing the pixels are either 00 or ff (black or white, 1 or 0)
- and are arranged in columns and rows.
When reading the file in memory, are the values in the memblock array stored as ff and 00 or are they converted into 1 and 0 automatically by ASCII or something?
When the data is stored as hex
and you read it using
file.readas shown in your code,then it is stored as that, which means that
will evaluate to true.
EDIT
You have to make the conversion yourself. One way would be