JosephH JosephH - 1 month ago 19
C Question

What is atoi equivalent for 64bit integer(uint64_t) in C that works on both Unix and Windows?

I'm trying to convert 64bit integer string to integer, but I don't know which one to use.

Answer

Use strtoull if you have it or _strtoui64() with visual studio.

unsigned long long strtoull(const char *restrict str,
       char **restrict endptr, int base);


/* I am sure MS had a good reason not to name it "strtoull" or
 * "_strtoull" at least.
 */
unsigned __int64 _strtoui64(
   const char *nptr,
   char **endptr,
   int base 
);