I am trying to implement the htoi(s) [Dennis Ritchie chapter2 exercise 2-3 Q] which converts a string of hexadecimal digits, into its equivalent integer, can anyone help me out in the logic of this program, i dont need the code, i just need the logic for implementing it. I am not able to get the correct logic
I am trying to implement the htoi(s) [Dennis Ritchie chapter2 exercise 2-3 Q] which
Share
Let’s take a step back:
How would you implement a function that accepts a single hex digit and returns it’s decimal equivalent?
In other words, how would you write this function:
Hint: for decimal digits what happens when you calculate
c -'0'?Once you have this function it should be fairly easy to use it to calculate the conversion of longer hex strings.
Hint: 0xF is 15 and 0x10 is 16