i am really struggling to load some numeric floating point data from a file into a C program...the file has floating point numbers with precision of 3 decimal points, each of which is in a single line...i wanted to load these values into an float array and then perform some calculations in it...however i tried loading it into an array of floats but it didn't store the values properly...i.e values like 123.45 were stored as 123.44999 or something..but i don't want this.
i tried to store this in a array of strings and then may be convert them into scaled integers. but i cannot get it to load into an array of string. can anyone tell me where i am going wrong. what i did is something like this.
unsigned char **data
............
data = malloc(sizeof(unsigned char *) * fileSize);
............
while (!feof(fp))
{
if (fscanf (fp, "%s", &data[j]) == 1) // if converted, increment counter
++j;
}
...........
i am a newbie so i am not so good with pointers. and after i load it into an string array, how do i convert it into scaled integers?