#include float strtof(const char *str, char **endptr) { float res = 0.0F; char *ptr = (char*)str; int after_dot = 0; float div = 1; while (*ptr != '\0') { if (isdigit(*ptr)) { if (!after_dot) { res *= 10; res += *ptr - '0'; } else { div *= 10; res += (float)(*ptr - '0') / div; } } else if (*ptr == '.') { after_dot = 1; } else { break; } ptr++; } if (endptr) { *endptr = ptr; } return res; }