cve.c (228B)
1 #include "cve.h" 2 3 int 4 cve(char *s, unsigned int *n) 5 { 6 int tmp; 7 8 if (*s == '\0') 9 return -1; 10 11 for (tmp = 0; *s != '\0'; s++) { 12 if (*s < '0' || *s > '9') 13 return -1; 14 tmp = tmp * 10 + *s - '0'; 15 } 16 *n = tmp; 17 return 0; 18 }