#include
#include
#include
#include
void insert(void);
void shop(void);
int check(void);
int pcheck(void);
void dandt(void);
void main()
{
int driver=DETECT,mode,s1;
int exit;
FILE *fp;
clrscr();
printf(" Loading Powerful 512MB accelerated graphics from\nSANJAY incorporate company ltd.\n\a");
sleep(1);
clrscr();
//initgraph(&driver,&mode,"L:\\turbocpp\\cga.bgi");
//setbkcolor(9);
//closegraph();
do
{
printf("\nWhat do You Want to do? insert(1) or shop(2)");
scanf("%d",&s1);
switch(s1)
{
case 1:
insert();
break;
case 2:
shop();
break;
default:
printf("Wrong choice");
}
printf("\n\n\nPress 1 to exit or 2 to goto menu");
scanf("%d",exit);
}
while(exit==2);
printf("\n\nBye");
getch();
}
void insert(void)
{
int pass,quantity,exit1,driver1=DETECT,mode1;
float price;
char item[40],code[10];
FILE *fp1,*ck;
//initgraph(&driver1,&mode1,"L:\\turbocpp\\cga.bgi");
//setbkcolor(6);
do
{
printf("\nType Item code: ");
scanf("%s",&code);
ck=fopen(code,"r");
if(ck!=NULL)
{
printf("\n\nCode already exists\n\n");
fclose(ck);
insert();
}
else
{
fclose(ck);
fp1=fopen(code,"w");
printf("\n\nType Item Name: ");
scanf("%s",&item);
printf("\n\nType Item price: ");
scanf("%f",&price);
printf("\n\nType Current Quantity: ");
scanf("%d",&quantity);
fprintf(fp1," %s\t%s\t%d\t%f",code,item,quantity,price);
printf("\n\n\n\nSuccessfully Written To File Name: %d",code);
fclose(fp1);
clrscr();
printf("\n\nDo You Want To add again(1) or not(2)");
scanf("%d",&exit1);
}
}
while(exit1==1);
}
int pcheck(void)
{
int password=123,passc,count=1;
do
{
printf("Type Password:");
scanf("%d",&passc);
if(passc!=password)
{
count++;
printf("\n\nWrong Password\n\n");
}
else
return(1);
}
while(count!=3);
}
void shop(void)
{
int driver2=DETECT,mode2,pass,bord,wer=0,count2=0,squantity;
char scode[10],v;
FILE *sp,*ck1;
clrscr();
initgraph(&driver2,&mode2,"L:\\turbocpp\\cga.bgi");
setbkcolor(6);
pass=pcheck();
if(pass!=1)
printf("\n\nBYE");
else
{
do
{
for(bord=0;bord<79;bord++)
printf("=");
//dandt();
printf("\n\nType Item Code: ");
scanf("%s",scode);
ck1=fopen(scode,"r");
if(ck1==NULL)
{
printf("\n\nItem Does not exists exists\n\n");
fclose(ck1);
wer=1;
count2++;
if(count2==3)
wer=0;
}
}
while(wer==1);
else
{
sp=fopen(scode,"r");
printf("\n\nProduct Information\n\n");
while((v=getc(sp))!=EOF)
printf("%c",v);
write2screen
getconfiguration();

No comments:
Post a Comment