#include #include #include #include typedef struct /* The Data Structure for one item of the inven- */ { int BarCode; /* tory. */ float UnitPrice; int Quantity; char Description[40]; } RECORD; main() {RECORD Product; FILE *fp; int Items,*total,count; char *S; fp=fopen("DATA","w+b"); printf("How Many Items >"); scanf("%d",&Items); fwrite(&Items,sizeof(int),1,fp); *total=0; for (count=0;count <= (Items-1);count++) { printf(">"); scanf("%s",S); Product.BarCode=atoi(S); scanf("%s",S); Product.UnitPrice=atof(S); scanf("%s",S); Product.Quantity=atoi(S); scanf("%s",Product.Description); *total+=Product.Quantity; fwrite(&Product,sizeof(RECORD),1,fp); } fwrite(total,sizeof(int),1,fp); fclose(fp); }