Database Project

Mar 24, 2017 at 2:53pm
PLZXX anyone helpout in removing the errors of this code..
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<graphics.h>
#include<dos.h>
#include<process.h>
#include<string.h>
#define SETPAL 0*0B


//graphics start**********************
void main() {
int x,y,cl,a,b;
cleardevice();
int gd=DETECT,gm,button;
//int f=0,v=12;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
rectangle(100,100,550,400);
getch(); }


void main(void){
char cm,ck,cl,cs,another;
char ch;
int gd=DETECT,gm,x,y,button;
int v=12,f=0;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");




setbkcolor(WHITE);
delay(90);
setfillstyle(SOLID_FILL,GREEN);
bar(65,20,80,330);
delay(90);
setfillstyle(SOLID_FILL,GREEN);
bar(65,20,180,330);
delay(90);
setfillstyle(SOLID_FILL,GREEN);
bar(65,20,280,330);
delay(90);
setfillstyle(SOLID_FILL,GREEN);
bar(65,20,580,330);
delay(90);


do
{



delay(100);
setfillstyle(SOLID_FILL,BLUE);
bar(65,420,580,330);
delay(35);

//char ch;

//int gd=DETECT,gm;
//initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
moveto(90,80);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,8);
setcolor(YELLOW);
delay(90);
outtext("WELCOME");



f++;



}





while(f!=v);
moveto(450,450);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
setcolor(BLUE);
delay(90);
outtext("PLEASE WAIT.......");



moveto(450,450);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
setcolor(BLUE);
delay(90);
outtext("press any key.......");




getch();
printf("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
delay(90);
printf("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
delay(90);
printf("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
delay(90);
gotoxy(10,30);

//getch();
//closegraph();



pass:
cleardevice();

setbkcolor(WHITE);
{

//char cm,ck,cl,cs,another;


puts("ENTER YOUR PASWORD\n\n\n");
gotoxy(42,15);
cm=getch();
printf("*");
ck=getch();
printf("*");
cl=getch();
printf("*");
cs=getch();
printf("*");



if(cm=='h' && ck=='i' && cl=='b' && cs=='a')
{
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
setbkcolor(DARKGRAY);
gotoxy(10,10);
setfillstyle(HATCH_FILL,WHITE);
bar(30,10,110,100);
setfillstyle(SLASH_FILL,WHITE);
bar(140,103,223,198);
setfillstyle(LINE_FILL,WHITE);
bar(272,198,355,290);
setfillstyle(SLASH_FILL,WHITE);
bar(380,103,470,198);
setfillstyle(HATCH_FILL,WHITE);
bar(510,10,590,100);

moveto(220,375);
settextstyle(GOTHIC_FONT,HORIZ_DIR,1);
outtext("U R WELCOME");

getch();}
else
{
moveto(180,200);
outtext("WRONG PASSWORD");
getch();
goto pass;

}

//graphic end**************
void input();
void writefile();
void search();
void output();


struct date
{
int month;
int day;
int year;
};

struct account
{
int number;
char name[100];
int acct_no;
float mobile_no;
char street[100];
char city[100];
char acct_type;
float oldbalance;
float newbalance;
float payment;
struct date lastpayment;
}customer;
int tl,sl,ts;

}
int i,n;
// char ch;
clrscr();
textcolor(WHITE);
_setcursortype(_NOCURSOR);
printf(" CUSTOMER BILLING SYSTEM:\n\n");
printf("===============================\n\n");
printf("1:to add account on list\n");
printf("2:to search customer account\n");
printf("3:exit\n");
printf("\n================================\n");
do
{
printf("\nselect what do you want to do?");
ch=getche();
}while(ch<='0' || ch>'3');
switch(ch){
case '1':
clrscr();
printf("\nhow many customer accounts?");
scanf("%d",&n);
for(i=0;i<n;i++)
{
// input();
if(customer.payment>0)
customer.acct_type=(customer.payment<0.1*customer.oldbalance)? 'O': 'D';
else
customer.acct_type=(customer.oldbalance>0)?'D' : 'C';
customer.newbalance=customer.oldbalance - customer.payment;
writefile();
}
main();
case '2':
clrscr();
printf("search by what?\n");
printf("\n1 --- search by customer number\n");
printf("2 --- search by customer name\n");
search();
ch=getche();
main();
case '3':
clrscr();
// delay(700);
textcolor(RED);
gotoxy(20,12);
cprintf("\nProject by http://www.turboc.codeplex.com");
//delay(5000);
exit(1);
}
}


void input()
{
FILE *fp=fopen("bidur.dat","rb");
fseek (fp,0,SEEK_END);
tl=ftell(fp);
sl=sizeof(customer);
ts=tl/sl;
fseek(fp,(ts-1)*sl,SEEK_SET);
fread(&customer,sizeof(customer),1,fp);
printf("\ncustomer no:%d\n",++customer.number);
fclose(fp);
printf("\tAccount number:");
scanf("%d",&customer.acct_no);
printf("\tName:");
scanf("%s",customer.name);
printf("\tMobile no:");
scanf("%f",&customer.mobile_no);
printf("\tStreet:");
scanf("%s",customer.street);
printf("\tCity:");
scanf("%s",customer.city);
printf("\tPrevious balance:");
scanf("%f",&customer.oldbalance);
printf("\tCurrent payment:");
scanf("%f",&customer.payment);
printf("\tPayment date(mm/dd/yyyy):");
scanf("%d/%d/%d",&customer.lastpayment.month,&customer.lastpayment.day,&customer.lastpayment.year);
return;
}

void writefile()
{
FILE *fp;
fp=fopen("bidur.dat","ab");
fwrite(&customer,sizeof(customer),1,fp);
fclose(fp);
return;
}

void search()
{
char ch;
char nam[100];
int n,i,m=1;
FILE *fp;
fp=fopen("bidur.dat","rb");
do
{
printf("\nenter your choice:");
ch=getche();
}while(ch!='1' && ch!='2');
switch(ch)
{
case '1':
fseek(fp,0,SEEK_END);
tl=ftell(fp);
sl=sizeof(customer);
ts=tl/sl;
do
{
printf("\nchoose customer number:");
scanf("%d",&n);
if(n<=0 || n>ts)
printf("\nenter correct\n");
else
{
fseek(fp,(n-1)*sl,SEEK_SET);
fread(&customer,sl,1,fp);
output();
}
printf("\n\nagain?(y/n)");
ch=getche();
}while(ch=='y');
fclose(fp);
break;
case '2':
fseek(fp,0,SEEK_END);
tl=ftell(fp);
sl=sizeof(customer);
ts=tl/sl;
fseek(fp,(ts-1)*sl,SEEK_SET);
fread(&customer,sizeof(customer),1,fp);
n=customer.number;
do{
printf("\nenter the name:");
scanf("%s",nam);
fseek(fp,0,SEEK_SET);
for(i=1;i<=n;i++)
{
fread(&customer,sizeof(customer),1,fp);
//if(strcmp(customer.name,nam)==0)
{
output();
m=0;
break;
}
}
if(m!=0)
printf("\n\ndoesn't exist\n");
printf("\nanother?(y/n)");
ch=getche();
}while(ch=='y');
fclose(fp);
}
return;
}
void output()
{
printf("\n\n\tCustomer no :%d\n",customer.number);
printf("\tName :%s\n",customer.name);
printf("\tMobile no :%.f\n",customer.mobile_no);
printf("\tAccount number :%d\n",customer.acct_no);
printf("\tStreet :%s\n",customer.street);
printf("\tCity :%s\n",customer.city);
printf("\tOld balance :%.2f\n",customer.oldbalance);
printf("\tCurrent payment :%.2f\n",customer.payment);
printf("\tNew balance :%.2f\n",customer.newbalance);
printf("\tPayment date :%d/%d/%d\n\n",customer.lastpayment.month,customer.lastpayment.day,customer.lastpayment.year);
printf("\tAccount status :");
textcolor(128+RED);
switch(customer.acct_type)
{
case 'C':
cprintf("CURRENT\n\n");
break;
case 'O':
cprintf("OVERDUE\n\n");
break;
case 'D':
cprintf("DELINQUENT\n\n");
break;
default:
cprintf("ERROR\\n\n");
}
textcolor(WHITE);
return;
}
Mar 24, 2017 at 8:28pm
Hello Werda,

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks

First question: is this a C program or C++ program. All your header files and code suggest a C program. The "graphics.h" is not available to me, so the program will not even compile. I see two void main() functions you can only have one main and it should be written as int main(). And you arw missing the return 0; just before the closing "}" of the real main function. Later in your code you call the main function to start over. This should not be done.

You have functions like textcolor() and gotoxy(). These are not standard functions and may be available with your compiler, which I think is outdated, and not available to everyone. This makes it hard for me to compile or test the program.

You have a link to a web site in your code, but you need to be more specific as to which page you are working from not just the home page.

That is a start. I will see what else I can find in a little while.

Hope that helps,

Andy
Last edited on Mar 24, 2017 at 8:31pm
Topic archived. No new replies allowed.