0

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.

3
Contributors
2
Replies
5
Views
9 Years
Discussion Span
Last Post by mathmagic
0

>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() );
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.