I just started this program a few hours ago, and I am running into an error that I do not understand. I tried finding an answer on Google as well. First off, this is the bare bones of a code right now. I have not started any of the sub-functions yet. All my goal is right now is to input the .txt file I created, and then print it back on the console so I can ensure the data is stored properly. The error I am getting is "error: expected primary-expression before '->' token" in my fscanf lines (Lines 26-29). I'm getting the same error in regards to the "." in my printf line (Line 32). My best guess is that my structure "measured_data_t" is created improperly, or I am referencing it improperly. Can someone assist me in better understanding my error?
#include <stdio.h>
#include <string.h>
#define ID_LEN 4
#define SPEED_LEN 2
#define DAY_LEN 2
#define TEMP_LEN 2
typedef struct {
int site_id_num[ID_LEN]; /* The site ID number for the station */
int wind_speed[SPEED_LEN]; /* The daily wind speed as measured at noon on the day_of_month */
int day_of_month[DAY_LEN]; /* The numerical day of the month measurements are made */
int temperature[TEMP_LEN]; /* The temperature as measured at noon on the day_of_month */
} measured_data_t;
int
main(void)
int i, MAX;
FILE *inp; /* File pointer to read text file */
/* Read data file into structure */
inp = fopen("weather_data.txt", "r");
printf("%-10s%-6s%-17s%-20s", "ID", "Day", "Wind Speed (knots)", "Temperature (deg C)");
fscanf("%d%d%d%d", measured_data_t->site_id_num,
measured_data_t->day_of_month,
measured_data_t->wind_speed,
measured_data_t->temperature);
for (i = 0; i <= MAX; i++)
{
printf("%-10d%-6d%-17d%-20d", measured_data_t.site_id_num, measured_data_t.day_of_month, measured_data_t.wind_speed, measured_data_t.temperature);
i++;
}
}
The overall goal of the program is to pull all the integer data from the text file, perform various calculations in sub functions, and then print them out. My concern is ensuring that I understand how to reference my structure properly prior to writing the rest of the code erroneously. Any help would be appreciated.