A direct analog of what you are doing with sprintf(3) would be to use sscanf(3) :
unsigned char *in; uint64_t out; sscanf(in, "%" SCNu64, &out);
But probably strtoull(3) will be easier and more efficient when handling errors:
out = strtoull(in, NULL, 0);
(This answer assumes that in does point to something similar to how out should point to something in your code example.)
source share