parseuint.c 261 B

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