1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define ArrSize 25
typedef struct Store{
char Brand[ArrSize];
char Object[ArrSize];
int ItemNumber;
int Quantity;
double Cost;
double Price;
}Inv;
void PrintCatalog(Inv Catalog[], int CatalogCount);
void Add(Inv Catalog[], int CatalogCount);
int main()
{
Inv Catalog[ArrSize]; int CatalogCount=6;
Catalog[0].ItemNumber=101;
strcpy(Catalog[0].Brand, "Nike");
strcpy(Catalog[0].Object, "Shoes");
Catalog[0].Quantity=4;
Catalog[0].Cost=39.99;
Catalog[0].Price=59.99;
Catalog[1].ItemNumber=102;
strcpy(Catalog[1].Brand, "Nike1");
strcpy(Catalog[1].Object, "Shoes1");
Catalog[1].Quantity=4;
Catalog[1].Cost=39.99;
Catalog[1].Price=59.99;
Catalog[2].ItemNumber=103;
strcpy(Catalog[2].Brand, "Nike2");
strcpy(Catalog[2].Object, "Shoes2");
Catalog[2].Quantity=4;
Catalog[2].Cost=39.99;
Catalog[2].Price=59.99;
Catalog[3].ItemNumber=104;
strcpy(Catalog[3].Brand, "Nike3");
strcpy(Catalog[3].Object, "Shoes3");
Catalog[3].Quantity=4;
Catalog[3].Cost=39.99;
Catalog[3].Price=59.99;
Catalog[4].ItemNumber=105;
strcpy(Catalog[4].Brand, "Nike4");
strcpy(Catalog[4].Object, "Shoes4");
Catalog[4].Quantity=4;
Catalog[4].Cost=39.99;
Catalog[4].Price=59.99;
Catalog[5].ItemNumber=106;
strcpy(Catalog[5].Brand, "Nike5");
strcpy(Catalog[5].Object, "Shoes5");
Catalog[5].Quantity=4;
Catalog[5].Cost=39.99;
Catalog[5].Price=59.99;
//PrintCatalog(Catalog, CatalogCount);
Add(Catalog, CatalogCount);
printf("%d\n", Catalog[6].ItemNumber);
return 0;
}
void Add(Inv Catalog[], int CatalogCount)
{
int X;
X=CatalogCount+1;
printf("Item Number:\n");
scanf("%d", Catalog[X].ItemNumber);
printf("Brand:\n");
scanf("%s", Catalog[X].Brand);
printf("Object:\n");
scanf("%s", Catalog[X].Object);
printf("Quantity:\n");
scanf("%d", Catalog[X].Quantity);
printf("Cost:\n");
scanf("%f", Catalog[X].Cost);
printf("Price:\n");
scanf("%f", Catalog[X].Price);
return;
}
|