read a line of float from file in struct

My file is
--------------------
1 1.3 0.10
2 0.9 2
3 2.0 0.5

I am doing this but not working...I want to read these in the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
typedef struct something {

    int id;
    float a;
    float b;
    float c;
    int *next; 
}var;
//main func
var v;
int number;
while(fscanf(fp,"%f", &number)==1){
       //read from file

       v.id=number;//say 1
       v.a=number;//say 1.3
       v.b=number;//say 0.10
       v.c=0.0;
      printf("%d, %0.2f, %0.2f, %0.2f\n",id,a,b,c);

       //printf("%0.2f", number);
       //read data
   }
At line 12, your code reads a single value. If you want to read three values from the file, change the fscanf to read three values into three variables. Also, number is of type int, it won't do very well at reading a floating-point value such as 1.3.
thanks!
Topic archived. No new replies allowed.