I want to convert a char to a float in language C. But atof() and strtof() are not working.
Here is some code, maybe someone could help me! The difficulty is that my number has a e-02 included
char temp = "6.345e-02"; // the original value is read from a file
float result;
result = atof(temp); //not working correct
result = strtof(temp, NULL); //also not working correct
edit: new code
FILE *file = fopen("file.txt", "r");
char c;
char *temp[11];
float result;
while((c=fgetc(file))!=EOF){
if(c=='\t'){
result = atof(temp); //here is the converting problem
printf("%.6f\n", result);
} else {
temp[i] = c;
}
}