ipunished
Junior Member level 3
- Joined
- Mar 15, 2011
- Messages
- 31
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- United Kingdom
- Activity points
- 1,504
I want to convert an image to a character array, I was able to find this code:
I understand most of it except this part:
can anyone explain this kine please and why is it here?
Thank you
Code:
void main()
{
fstream image;
image.open("C:\\pic.bmp", std::ios_base::binary); //open pic in binary mode
image.seekg (0, ios::end); //count from end of file to beginning
int n = image.tellg(); //store current position of pointer in n
image.seekg (0, ios::beg); //count from beginning of file
char* res = new char[n];
for(int i = 0; i < n; i++)
res[i] = '5';
bool bit = image.eof();
image.read(res, n);
}
I understand most of it except this part:
res = '5';
can anyone explain this kine please and why is it here?
Thank you