i need to get scan a input of (octal or hexadecimal) for this what specificer should i use in common to hexadecimal and octal

94 Views Asked by At

Am I able to get input of octal or hexadesimal number by using a common specifer for both in c program Or what should do to know the input type

1

There are 1 best solutions below

0
Allan Wind On

Writing up @Barmar's suggestion:

#include <stdio.h>

int main() {
        int i;
        scanf("%i", &i);
        printf("%d\n", i);
        return 0;
}

and example run with octal and hex input::

010
8
0x10
16