parseulong.c 261 B

123456789101112131415161718192021
  1. #include <format.h>
  2. char* parseulong(char* buf, unsigned long* np)
  3. {
  4. unsigned long n = 0;
  5. int d;
  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. }