Originally Posted by
Salem
Yes, pairs of fgets() calls into two separate buffers.
From the first buffer you extract the name, and from the second buffer you extract all the attributes.
Tried this out but did not work. Where am I wrong ?
Code:
int main()
{
FILE *fp;
fp = fopen("Pica das Galaxia FC.txt", "r");
//read file into array
float numberArray[SIZE];
char names[3][255];
float atributes[3][50];
int i,j;
if (fp == NULL)
{
printf("Error Reading File\n");
exit (0);
}
fgets(names[1], 255, (FILE*)fp);
fgets(names[2], 255, (FILE*)fp);
printf("Name is: %s\n", names[1]);
sscanf(names[2], "%f %f %f %f %f %f %f %f %f %f", atributes[0][0], atributes[0][1], atributes[0][2], atributes[0][3], atributes[0][4], atributes[0][5], atributes[0][6], atributes[0][7], atributes[0][8], atributes[0][9]);
for( i = 0; i < 10; i++)
{
printf("Number is: %.1f\n", atributes[1][i]);
}
fclose(fp);
return 0;
}