#include #include #define HEIGHT 0 #define WIDTH 1 typedef struct { char brand[31]; char modelName[31]; int modelNumber; double price; double screenSize[2]; } Phone; Phone readOnePhone(char brand[]) { Phone onePhone; strcpy(onePhone.brand, brand); scanf("%s", onePhone.modelName); scanf("%d", &onePhone.modelNumber); scanf("%lf", &onePhone.price); scanf("%lf", &onePhone.screenSize[HEIGHT]); scanf("%lf", &onePhone.screenSize[WIDTH]); return onePhone; } void printOnePhone(Phone p) { printf("Brand: %s\n", p.brand); printf("Model: %s\n", p.modelName); printf("Number: %d\n", p.modelNumber); printf("Price: $%6.2f\n", p.price); printf("Size: %4.2f x %4.2f\n\n", p.screenSize[HEIGHT], p.screenSize[WIDTH]); } int main(void) { Phone inventory[100]; char firstString[31]; int i = 0, size; printf("Enter Brand, Model, Number, price, screen height, screen width (-1 to end)\n"); scanf("%s", firstString); while (strcmp(firstString, "-1") != 0) { inventory[i++] = readOnePhone(firstString); scanf("%s", firstString); } size = i; for (i = 0; i < size; i++) { printOnePhone(inventory[i]); } return 0; }