# include & ltstdlib.h & gt
# include & ltstring.h & gt
# include & ltconio.h & gt
Structural ima
{
int id
char name[20];
Carbonization product [30];
Int number;
Floating price;
};
void Append();
void sell delete();
void Amend();
void Findin();
void Browse()。
void colorsetting();
void end program();
Void initialization ()
{
FILE * fp
Struct ima i={ 1, "peanut milk", "Wuhan, Hubei",1200,2.5};
Fp=fopen("ima.dat evil "," W ");
if(fp==NULL)
{
Printf ("\ t \ t \ tSystem error, please try again. ...................................................................................................................................................
Exit (0);
}
fwrite(& amp; I,sizeof(struct ima), 1,FP);
fclose(FP);
}
Invalid menu ()
{
Int selection;
Supermarket inventory management system
Printf ("-The system menu is shown below.
Printf ("\ n \ t1= = = = = = = = = = = = = = = = = = = = = = = = Newly purchased items are put into storage \ n");
Printf ("\ n \ t2 = = = = = = = = = = = = = = = = = = Project information has been deleted \ n");
Printf ("\ n \ t3 = = = = = = = = = = = = = = = = = = Project information modification \ n");
Printf ("\ n \ t4 = = = = = = = = = = = = = = = = = = = Item information query \ n");
Printf ("\ n \ t5 = = = = = = = = = = = = = = = = = = = = browse item information \ n");
Printf ("\ n \ t6 = = = = = = = = = = = = = = = = = = = = Application exits \ n");
Printf ("\ n \ tPlease enter the menu you want to select ...");
Scanf("%d ",& select);
Switch (selection)
{
Case 1:
append();
Break;
Case 2:
sell delete();
Break;
Case 3:
amend();
Break;
Case 4:
findin();
Break;
Case 5:
browse();
Break;
Case 6:
end program();
Break;
Default value:
Printf(" \ n \ t \ t \ t \ t \ t tInvalid input, please re-enter ... ");
getch();
System ("CLS");
menu();
}
}
int validateID(int id)
{
FILE * fp
Structure IMA I;;
fp=fopen("ima.date "," r ");
if(fp==NULL)
{
Printf ("\ t \ t \ tSystem error, please try again. ...................................................................................................................................................
Exit (0);
}
Fred (& ampI, sizeof (structurima), 1, fp);
And (! feof(fp))
{
if(i.id==id)
{
fclose(FP);
Returns1;
Break;
}
Fred (& ampI, sizeof (structurima), 1, fp);
}
fclose(FP);
Returns 0;
}
Void addition ()
{ struct IMA I;
Char selection;
FILE * fp
fp=fopen("ima.date "," ab ");
if(fp==NULL)
{
Printf ("\ t \ t \ tSystem error, please try again. ...................................................................................................................................................
Exit (0);
}
labID:
Printf ("\ n \ tPlease enter the project information to be put into storage ... \ n");
printf(" \ t \ t \ t \ tItem number:");
scanf("%d ",& ampI . id);
if(validateID(i.id)== 1)
{
Printf ("\ t \ t \ t \ tThis number has already been used, please re-enter ...");
goto labID
}
Printf(" \ t \ t \ t \ t tProject name: ");
scanf("%s ",I . name);
Printf ("\ t \ t \ t \ tPlace of production:");
scanf("%s ",I . produce);
Printf ("\ t \ t \ tItem Quantity:");
Scanf("%d ",&No.);
Printf(" \ t \ t \ t \ t unit price of this project: ");
Scanf("%f ",& ampI. price);
fwrite(& amp; I,sizeof(struct ima), 1,FP);
fclose(FP);
Printf ("\ t \ t \ t \ t \ t \ tProject information has been successfully received! ! ! \ n ");
Printf ("\ nDo you want to continue? (y/n)");
Scanf(" %c ",& select);
if(choice=='Y'||choice=='y ')
{
append();
}
other
{
System ("CLS");
menu();
}
}
void Selldelete()
{ struct IMA I[ 1000];
Structural ima temperature;
int delID
Char selection;
int index = 0;
int j = 0;
FILE * fp
fp=fopen("ima.date "," r ");
if(fp==NULL)
{
Printf ("\ t \ t \ tsystem error, please try ............................................................................. again"));
Exit (0);
}
Fred (& amptemp, sizeof (structurima), 1, fp);
And (! feof(fp))
{
I[index]= temp;
index++;
Fred (& amptemp, sizeof (structurima), 1, fp);
}
fclose(FP);
Printf ("\ n \ tPlease enter the number of the item to be deleted:");
scanf("%d ",& ampdelID);
fopen("f:\\ima.date "," w ");
if(fp==NULL)
{
Printf ("\ t \ t \ tsystem error, please try ............................................................................. again"));
Exit (0);
}
for(j = 0; J< index; j++)
{
if(i[j]。 id! =delID)
{
fwrite(& amp; i[j],sizeof(struct ima), 1,FP);
}
}
fclose(FP);
Printf(" \ t \ t \ t \ t \ t tProject information has been cleared! ! ! \ n ");
Printf ("\ nDo you want to continue? (y/n)");
Scanf(" %c ",& select);
if(choice=='Y'||choice=='y ')
{
sell delete();
}
other
{
System ("CLS");
menu();
}
}
Void correction ()
{ int index = 0;
int ID,j;
Char selection;
struct IMA I[ 1000];
Structural ima temperature;
FILE * fp
fp=fopen("ima.date "," r ");
if(fp==NULL)
{
Printf ("\ t \ t \ tSystem error, please try again. ...................................................................................................................................................
Exit (0);
}
Fred (& amptemp, sizeof (structurima), 1, fp);
And (! feof(fp))
{
I[index]= temp;
index++;
Fred (& amptemp, sizeof (structurima), 1, fp);
}
fclose(FP);
fp=fopen("ima.date "," w ");
if(fp==NULL)
{
Printf(" \ \ t \ t \ t tSystem error, please try ........................................................................... again);
Exit (0);
}
Printf ("\ n \ tPlease enter the item number of the information to be modified:");
scanf("%d ",& ampID);
for(j = 0; j & lt= index- 1; j++)
{
if(i[j]。 id! =ID)
{
fwrite(& amp; i[j],sizeof(struct ima), 1,FP);
}
other
{
Printf ("\ t \ tItem name changed to: ");
Scanf("%s ",i[j]. Name);
Printf ("\ t \ tThe place of production of articles is changed to");
Scanf("%s ",i[j]. generated);
Printf ("\ t \ tThe number of items is changed to");
Scanf("%d ",& [j]. No.);
Printf ("\ t \ tThe unit price of goods is changed to");
Scanf("%f ",& [j]. Price);
fwrite(& amp; i[j],sizeof(struct ima), 1,FP);
}
}
fclose(FP);
Printf ("\ t \ t \ t \ tProject information has been modified ...");
Printf ("\ nDo you want to continue? (y/n)");
Scanf(" %c ",& select);
if(choice=='Y'||choice=='y ')
{
amend();
}
other
{
System ("CLS");
menu();
}
}
void Findin()
{
FILE * fp
Intfindchar selection; Structure IMA I;;
fp=fopen("ima.date "," r ");
if(fp==NULL)
{
Printf ("\ t \ t \ tSystem error, please try again. ...................................................................................................................................................
Exit (0);
}
finID:
Printf ("\ n \ tPlease enter the item number to be queried ...");
scanf("%d ",& ampfindID);
Fred (& ampI, sizeof (structurima), 1, fp);
And (! feof(fp))
{
if(i.id==findID)
{
Printf ("\ n \ n \ t * * * * * * * * * * * Project information * * * * * * * * * *);
Printf ("\ n \ tProject number ... %30d\n", i.id);
printf(" \ n \ t-");
Printf ("\ n \ tProject name ... %30s\n", i.name);
printf(" \ n \ t-");
Printf ("\ n \ tManufacturer ... %30s\n", i.produce);
printf(" \ n \ t-");
Printf ("\ n \ tImported quantity ... %30d\n", ID number);
printf(" \ n \ t-");
Printf ("\ n \ tWholesale price ... %30.3f\n", i.price);
printf(" \ n \ t-");
Printf ("\ nDo you want to continue? (y/n)");
Scanf(" %c ",& select);
if(choice=='Y'||choice=='y ')
{
findin();
}
other
{
System ("CLS");
menu();
}
}
Fred (& ampI, sizeof (structurima), 1, fp);
}
fclose(FP);
Printf ("\ t \ t \ t \ t \ tThe number entered does not exist, please re-enter ...");
goto finID
}
Void browse ()
{ struct IMA I;
int index = 0;
Char selection;
FILE * fp
fp=fopen("ima.date "," r ");
if(fp==NULL)
{
Printf ("\ t \ t \ tSystem error, please try again. ...................................................................................................................................................
Exit (0);
}
Fred (& ampI, sizeof (structurima), 1, fp);
And (! feof(fp))
{
index++;
Printf(" \ n \ n \ t * * * * * * * * * * * * * information% d * * * * * * * * * * index);
Printf ("\ n \ tProject number ... %30d\n", i.id);
printf(" \ n \ t-");
Printf ("\ n \ tProject name ... %30s\n", i.name);
printf(" \ n \ t-");
Printf ("\ n \ tManufacturer ... %30s\n", i.produce);
printf(" \ n \ t-");
Printf ("\ n \ tImported quantity ... %30d\n", ID number);
printf(" \ n \ t-");
Printf ("\ n \ tWholesale price ... %30.3f\n", i.price);
printf(" \ n \ t-");
getch();
Fred (& ampI, sizeof (structurima), 1, fp);
}
fclose(FP);
Printf ("\ nDo you want to continue? (y/n)");
Scanf(" %c ",& select);
if(choice=='Y'||choice=='y ')
{
browse();
}
other
{
System ("CLS");
menu();
}
}
void Endprogram()
{ char choice
System ("CLS");
Printf(" \ n \ n \ n \ n \ n \ n \ t \ t \ tAre you sure you want to exit the system? \ n \ n \ n \ t \ tIf you want to quit, please press the "Y" key and other keys will return to the main menu ... ");
Scanf(" %c ",& select);
if(choice=='Y'||choice=='y ')
{
System ("CLS");
Printf ("\ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ t \ tThank you for using it! ! !" );
printf(" \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n ");
}
other
{
System ("CLS");
menu();
}
}
void main()
{
printf(" \ n \ n ");
printf(" \ t \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ n ");
Printf("\t\3 Welcome \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ n ");
Printf("\t\3 Supermarket Inventory Management System \ 3 \ n ");
Printf("\t\3 Press any key to continue \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ n ");
printf(" \ t \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3 \ 3);
getch();
System ("CLS");
menu();
Initialize ();
menu();
}