I am trying to convert some data that I read in file as string data to a float array

The data that is read are in two dimensional string array like

char tmatrix[10][100];
for(j=0;j<k3;j++){printf("\n %s",tmatrix[j]);}   //k3=max data read

Now I need to convert the content of tmatrix[][] into a float array
so that float_array[1]=0.5

Recommended Answers

All 3 Replies

No problem -- just call atof()

float n = atof(tmatrix[i]);

Not a perfrect solution, but works ok for most purposes.

commented: Nope -3

Thanks a lot :D

strtod() would be a better function to use, because it has better error diagnostics.

commented: Very true +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.