Once a file is read, how would you store the information into an array of nine elements where each element is a structure named data_t.
Once a file is read, how would you store the information into an array of nine elements where each element is a structure named data_t.
You are going to have to provide more information.
Fact - Beethoven wrote his first symphony in C
I need to store information from a file that contains stats of ten different countries, and store that information in an array of ten elements, where each element is a structure named data_t.
What have you done so far?
Fact - Beethoven wrote his first symphony in C
I defined a structure and called the file for reading, but I am confused about how to store the information in the fscanf portion of the code.
Code:typedef struct { int ranking; char name[20]; char state[2]; float population, percent; } city_t[9];
Code:for (i = 0; i < 9; i++) { fscanf(fp, "%d %s %s %f %f", &city_t[i].ranking, city_t[i].name, city_t[i].state, &city_t[i].population, &city_t[i].percent); }