I don't know how to convert a string value to double or float. Here is the sample string I am trying to convert: "3.45667". I am struggling with the handling of the dot.
I tried this but it is not working:
#include<stdio.h>
int main()
{
char string_array[] = { "3.45667" };
float float_array[20], index = 0;
for(index = 0 ; index < 7 ; index++)
{
if(string_array[index] == '.')
{
printf("dot");
// here, how to add dot to the float_array?
} else
{
float_array = (float)(string_array[index] - '0');
}
}
return 0;
}
How to add a decimal point in the above code? I think this could be done with exponent form but I don't know how to use exponent form.