std::streampos size;
char * memblock;
std::ifstream input ("A.JPG", std::ios::in|std::ios::binary|std::ios::ate);
if (input.is_open())
{
size = input.tellg();
memblock = new char [size];
input.seekg (0, std::ios::beg);
input.read (memblock, size);
input.close();
std::cout << "[INPUT]the entire file content is in memory " << sizeof(memblock) << "
";
}
delete[] memblock;
I would like to use the ifstream to read A.JPG (28KB) and save it into the array memblock. But why do the size of the memblock is 4 instead of 28403 while the variable size is equal to 28403?
Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…