I keep getting a formatting error and I am not sure of how adjust my code.
int main()
{
FILE* fp=fopen("food.txt","r");
float costs_2018[10];
float costs_2020[10];
char* name[1000][10];
char* quantity[1000][10];
fscanf(fp,"%s %s %s %s",&name[0], &quantity[0], &costs_2018[0], &costs_2020[0]);
for (int i=0;i<10;i++)
{
fscanf(fp,"%s %d%*s %f %f",&name[i],&quantity[i],&costs_2018[i],&costs_2020[i]);
}
printf("total cost in 2018 is = %f",calculate_total_cost(costs_2018));
printf("\ntotal cost in 2020 is = %f",calculate_total_cost(costs_2020));
printf("\naverage cost in 2018 is = %f",calculate_total_average(costs_2018));
printf("\naverage cost in 2020 is = %f",calculate_total_average(costs_2020));
printf("\nDifference in total price between 2018 and 2020 is = %f",calculate_total_cost(costs_2018)-calculate_total_cost(costs_2020));
printf("\nDifference in average price between 2018 and 2020 is = %f",calculate_total_average(costs_2018)-calculate_total_average(costs_2020));
return 0;
}
on both of my "fscanf" lines im getting a formatting error. The first fscanf line name,quantity,costs_2018,costs2019 are underlined red. The 2nd fscanf line just name and quantity are underlined red.