parseoct.c 232 B

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