/* some structures */ #include #include int main() { /* first, declare the structure */ struct parts { char partname[10]; int count; float cost; }; /* this time, let's do an array of structures */ struct parts inventory[7]; int i; FILE *fileptr; /* time to grab some data */ fileptr = fopen("03_indata.txt", "r"); for (i=0; i<5; i++) { fscanf(fileptr, "%s %d %f", inventory[i].partname, &inventory[i].count, &inventory[i].cost); } fclose(fileptr); /* print out the data */ for (i=0; i<5; i++) { printf("Partname: %s\n", inventory[i].partname); printf("Count: %d\n", inventory[i].count); printf("Cost per unit: %.2f\n\n", inventory[i].cost); } }