Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /**
- * Hexadecimal number to integer
- */
- static int c2n(int c) {
- return c - (c&64?:87:48);
- }
- int main(void) {
- char c;
- printf("Enter hexadecimal number: ");
- scanf("%c", &c);
- printf("%d\n", c2n(c));
- return 0;
- }
Add Comment
Please, Sign In to add comment