parseint64.c 273 B

12345678910111213141516171819202122
  1. #include <bits/types.h>
  2. #include <format.h>
  3. char* parseu64(char* buf, uint64_t* np)
  4. {
  5. uint64_t n = 0;
  6. int d;
  7. char* p;
  8. for(p = buf; *p; p++)
  9. if(*p >= '0' && (d = *p - '0') < 10)
  10. n = n*10 + d;
  11. else
  12. break;
  13. if(p == buf)
  14. return NULL;
  15. *np = n;
  16. return p;
  17. }