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
|
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
struct product{
char C[5], NAME[10];
int Q;
};
int main ()
{
struct product X[20];
int ctr, N;
char choice;
FILE *fp;
fp = fopen("Inventory1.txt","w");
printf("\nHow Many Products:\t");
scanf("%d", &N);
for (ctr=0; ctr<N; ctr++)
{
printf("\n\n%d. Product Code:\t", ctr+1);
scanf("\n");
gets(X[ctr].C);
printf(" Product Name:\t");
scanf("\n");
gets(X[ctr].NAME);
printf(" Quantity:\t\t");
scanf("\n%d", &X[ctr].Q);
}
for (ctr=0; ctr<N; ctr++)
{
fprintf(fp, "\n\n%s\n%s\n%d", X[ctr].C, X[ctr].NAME, X[ctr].Q);
}
printf("Do you want to update the inventory [Y/N]? ");
scanf(" %c", &choice);
if (toupper(choice) == 'y')
{
if (X[ctr].C != ) // validating the code whether it exist or not
{
}
else
{
printf("Record not found!");
}
for (ctr=0;strcmp(goods[ctr].C,D)!=0;ctr++);
{
if (UC=='a'||UC=='A')
goods[ctr].Q+=X;
else if (UC=='s'||UC=='S')
goods[ctr].Q-=X;
}
}
else
{
for (ctr=0; ctr<N; ctr++)
{
printf("\n%s \t\t\t %s \t\t %d", goods[ctr].C, goods[ctr].NAME, goods[ctr].Q);
}
}
fclose(fp);
getch();
}
|