Making sense of this image to array code

Status
Not open for further replies.

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
Visit site
Activity points
1,504
I want to convert an image to a character array, I was able to find this code:

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
 

ok so i wrote it and ran the file and it did what i thought its writing every point in res equal to 5.. dont know why..

I want res to equal or take the value of image opened.. how do I do that?

Thanks
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…