Posted 27 September 2007 - 09:34 PM
I think this is going to be easy and I'm pretty sure I did this in beginner programming a few years ago without having to write a whole bunch of code to do so. I've been given a large file of hex numbers that I need to convert to decimal. This wouldn't be a problem if they had the 0x in front of them:
int x = 0x20;
cout << x; //prints 32 which is the decimal form.
Unfortunately, they are formatted like : 20 14 6f 3e
So, if I try to read each of these hex numbers from the file it's going to read them as a decimal which they are not due to no 0x prefix. Is there any way to read a number into the program and convert it easily without writing a large subroutine?