Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Making sense of this image to array code

Status
Not open for further replies.

ipunished

Junior Member level 3
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:

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top