i aware strtol(hexstring, null, 16)
convert string hexstring
, hexadecimal, decimal. likewise case in binary in strtol(binstring, null, 2)
. there function in general? 1 base next? if not, can propose line-efficient way?
op ready knows how convert string s
representing base
digits integer. sample usage:
char *endptr; errno = 0; unsigned long y = strtoul(s, &endptr, base); if (endptr == s) no_conversion(); if (errno) handle_overflow(); if (*endptr) handle_trailingtext();
an easy away convert unsigned integer uses compound literal memory allocation.
how use compound literals fprintf()
multiple formatted numbers arbitrary bases?
if need other methods, search on 0123456789abcdefghijklmnopqrstuvwxyz
.
Comments
Post a Comment