K&R Exercises

Exercise 2-3: Convert hexadecimal to an integer

Write a function htoi(s), which converts a string of hexadecimal digits (including an optional 0x or 0X) into its equivalent integer value. The allowable digits are 0 through 9, a through f, and A through F.

Each input line holds one such string, whose value fits in an int. Print each value in decimal on a line of its own.

Test Cases

· space→ tab↵ newline

Submissions

No submissions yet