'i need to get scan a input of (octal or hexadecimal) for this what specificer should i use in common to hexadecimal and octal
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
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Allan Wind |
