If not use atof, how can I complete the following function which can convert string to float?? Thanks..
Code:
#include <stdio.h>
#include <ctype.h>
#include <math.h>
float strToFloat(const char s[]) {
/* Add your code here */
}
int main() {
printf("%f\n", strToFloat("1"));
printf("%f\n", strToFloat(" 1.23"));
printf("%f\n", strToFloat("-1.23"));
printf("%f\n", strToFloat("1.23456"));
printf("%f\n", strToFloat("0.00000001"));
printf("%f\n", strToFloat("0.0.1"));
printf("%f\n", strToFloat("1E2"));
printf("%f\n", strToFloat("0.0.1"));
printf("%f\n", strToFloat("1.23456E2"));
printf("%f\n", strToFloat("1.23456e3"));
printf("%f\n", strToFloat("2E"));
}