long my_strtol(const char *str) { char *p = (char *) str; long res = 0; int sign = 0, temp = 0; while (my_isspace(*p)) { p++; } if (*p == '-') { sign = 1; p++; } else if (*p == '+') { sign = 0; p++; } while (*p) { if (my_isnum(*p)) { temp = *p - '0'; res = res*10 + temp; p++; } else { res = -999999; break; } } if (sign) res = -res; return res; }
int is_flag(char c) { if (my_isnum(c) == 1) return (1); if (c == '.') return (1); return (0); }
char *fill_space(char *str) { int i; i = 0; while (str[i]) { if ((my_isnum(str[i])) || str[i] == '-') return (&str[i]); i++; } return (NULL); }
int my_fgeti(t_fle *file) { int i; int j; char buff[12]; i = 0; if (file == NULL) return (0); while ((j = my_fread(file, buff + i, 1)) > 0 && my_isnum(buff[i]) && i++ < 11) buff[i + j] = '\0'; return (my_atoi(buff)); }
int my_isnum(char *str) { char *tmp; tmp = str + 1; if (*str >= '0' && *str <= '9') { if (*tmp == '\0') { return (1); } else { return (my_isnum(str + 1)); } } else { return (0); } }