According to the current C standard, C11, 7.21.6.2/12, only %i
deduces the base from the context, all other specifiers fix the base:
i
Matches an optionally signed integer, whose format is the same as expected for the subject sequence of thestrtol
function with the value 0 for thebase
argument. The corresponding argument shall be a pointer to signed integer.
o
Matches an optionally signed octal integer, whose format is the same as expected for the subject sequence of thestrtoul
function with the value 8 for thebase
argument. The corresponding argument shall be a pointer to unsigned integer.
u
Matches an optionally signed decimal integer, whose format is the same as expected for the subject sequence of thestrtoul
function with the value 10 for thebase
argument. The corresponding argument shall be a pointer to unsigned integer.
x
Matches an optionally signed hexadecimal integer, whose format is the same as expected for the subject sequence of thestrtoul
function with the value 16 for thebase
argument. The corresponding argument shall be a pointer to unsigned integer.