-4

I am trying to read the data from file pointed by f into my struct array: r_a[], but I am getting the error: expected expression before r_a" on the fscanf() line.

header file:

void setAsset(FILE *f);

  typedef struct rescue_asset{
      char callsign[31];
      char type;
      char location[31];
      double lat;
      double lng;
      double operational_speed;
      int maxDeployDuration;
      int lot_to_service;    
  }r_a[51];

c file:

#include "rescue_assets.h"
void setAsset(FILE * f)
{
    int i = 0;

    while (getchar() != EOF)
    {
        fscanf(f, "%s %c %s %f %f %f %d %d", &r_a[i].callsign, &r_a[i].type,
               &r_a[i].location, &r_a[i].lat, &r_a[i].lng, &r_a[i].operational_speed,
               &r_a[i].maxDeployDuration, &r_a[i].lot_to_service);

        ++i;
    }
}
Andrea Colleoni
  • 5,919
  • 3
  • 30
  • 49
user2069328
  • 71
  • 1
  • 7
  • 2
    Simplify your code. Find the smallest amount that still causes the problem. Then you will see the issue and/or can post it again. – Dwayne Towell Dec 10 '13 at 19:43

1 Answers1

0
typedef struct rescue_asset{
  char callsign[31];
  char type;
  char location[31];
  double lat;
  double lng;
  double operational_speed;
  int maxDeployDuration;
  int lot_to_service;
}r_a_t;

r_a_t r_a[51];

as you have to use a variable not a type. Another strange thing is your loop

while (getchar() != EOF)

you should check for i <51 and fscanf return value

Jekyll
  • 1,434
  • 11
  • 13