Hi all,
In graphics mode, I need to read hexadecimal value from a file and assign it to variable for which i can add other value later.
Eg : I need to read value 1007(hexadecimal) from a file and assign it to a variable.
Later when i add 3 to the stored hexadecimal value i need to get 100A and i need to print this value.

Recommended Answers

>I need to read value 1007(hexadecimal) from a file and assign it to a variable.
Use the std::hex manipulator (it's in the <ios> header):

in>> std::hex >> value;

>and i need to print this value.
You mentioned graphics mode, so you probably need to convert the value …

Jump to Post

All 2 Replies

>I need to read value 1007(hexadecimal) from a file and assign it to a variable.
Use the std::hex manipulator (it's in the <ios> header):

in>> std::hex >> value;

>and i need to print this value.
You mentioned graphics mode, so you probably need to convert the value into a string for display. Keep in mind that the value in memory isn't in hexadecimal (that's strictly a representation), so you can use a stringstream to do the reverse of reading the value:

std::stringstream out;

value += 3;
out<< std::hex << value;

// Or however you display the result
Display ( out.str() );

........................

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.