Add to Favorites    Make Home Page 2515 Online  
 Language Categories  
 Our Services  

Home » C Home » Beginners / Lab Assignments Home » Simple Account software

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Simple Account software
Author Deepesh Jain
Author Email talkdeepesh [at] yahoo.co.in
Description To save the balance of the customers.
Includes : 1.Addition of new acc.
2.Show acc
3.modify acc
4.del acc
5.search acc
Special features : * Usage of file handling
* Usage of Mouse programing
* Usage of graphic mode
How to use
Here are two files :
(1) Custm.exe
(2) record.txt
save the record.txt to the location "C:" .
execute Custm.exe
Your are requested to run this and give your valuable suggetions !
Thanking You !
contact talkdeepesh@yahoo.co.in Deepesh Jain
Category C » Beginners / Lab Assignments
Hits 370359
Code Select and Copy the Code
#include<graphics.h> #include<dos.h> #include<alloc.h> #include<stdio.h> #include<string.h> union REGS i,o; char *menu[]={"1.Add Records","2.Show Records","3.Modify Records", "4.Del Records","5.Search Record","6.Exit"}; main() { int gd=DETECT,gm,choice=1,width=0,i,count,sr=0; char **buffer; FILE *m,*t; char sname[20]; long int size; char mrec; struct cust { char name[20]; int accno; float balance; }; struct cust s; m=fopen("C:\record.txt","rb+"); if(m==NULL) { t=fopen("C:\record.txt","wb+"); if(t==NULL) { printf("Error in opening file "); exit(); } } size=sizeof(s); initgraph(&gd,&gm,"C:\Tc\Bgi"); setbkcolor(1); setcolor(11); if(initmouse()==0) { printf(" Mouse driver not loaded..."); exit(); } count=sizeof(menu)/sizeof(char *); settextstyle(TRIPLEX_FONT,0,3); displaymenu(menu,count,10,10); for(i=0;i<count;i++) { if(textwidth(menu[i])>width) width=textwidth(menu[i]); } // movemouseptr(&x1,&y1); buffer=malloc(sizeof(menu)); savemenu(menu,buffer,width,count,10,10); showmouseptr(); while (1) { displaymenu(menu,count,10,10); choice=getresponse(menu,buffer,width,count,10,10); gotoxy(50,15); hidemouseptr(); switch (choice) { case 1 : cleardevice(); fseek(m,0,SEEK_END); mrec='y'; gotoxy(1,1); while(mrec=='y') { printf(" Enter the Name of the Custumer "); scanf("%s",s.name); printf(" Enter the Acc.no of the Custumer "); scanf("%d",&s.accno); printf(" Enter the Balance of the Custumer "); scanf("%f",&s.balance); fwrite(&s,size,1,m); printf(" Are there more Records (Y/N)"); fflush(stdin); mrec=getche(); } printf("Press any key to go back to menu"); cleardevice(); break; case 2: cleardevice(); rewind(m); gotoxy(1,1); printf(" Name Acc.No Ammount Due "); sr=0; if(fread(&s,size,1,m)==1) { rewind(m); while(fread(&s,size,1,m)==1) { printf(" %30s%12d%23.2f",s.name,s.accno,s.balance); sr++; } } else printf(" There is no record to Display"); printf(" There are %d Records",sr); printf(" Press any key to go back to menu"); getch(); cleardevice(); break; case 3: clearviewport(); mrec='y'; gotoxy(1,1); while(mrec=='y') { printf(" Enter the name of Customer whose rec. is to be modified "); scanf("%s",sname); // gets(sname); rewind(m); while (fread(&s,size,1,m)==1) { sr=0; if( strcmp (s.name,sname)==0) { sr=1; // printf(" Enter new name,Acc.no,Balance "); // scanf("%s%d%f",s.name,&s.rollno,&s.percent); printf(" Enter the new Name of the Custumer "); scanf("%s",s.name); // gets(s.name); printf(" Enter the new Acc.no of the Custumer "); scanf("%d",&s.accno); printf(" Enter the new Balance of the Custumer "); scanf("%f",&s.balance); fseek(m,-size,SEEK_CUR); fwrite(&s,size,1,m); break; } } if(sr==0) printf(" Record "%s" is not found",sname); printf(" Modify more records (Y/N)"); fflush(stdin); mrec=getche(); } clearviewport(); break; case 4: clearviewport(); mrec='y'; gotoxy(1,1); while(mrec=='y') { printf(" Enter the name of the Customer to delete the rec "); scanf("%s",sname); // gets(sname); t=fopen("C:\stemp.txt","wb"); rewind (m); while(fread(&s,size,1,m)==1) { if(strcmp(s.name,sname)!=0) fwrite(&s,size,1,t); } fclose(m); fclose(t); remove("C:\record.txt"); rename("C:\stemp.txt","C:\record.txt"); m=fopen("C:\record.txt","rb+"); printf("Delete more records (Y/N)"); fflush(stdin); mrec=getche(); } clearviewport(); // displaymenu(menu,count,10,10); // getch(); // choice=getresponse(menu,buffer,width,count,10,10); break; case 5: clearviewport(); mrec='y'; gotoxy(1,1); while(mrec=='y') { printf(" Enter the name of Customer whose rec. is to be Searched "); scanf("%s",sname); // gets(sname); rewind(m); while (fread(&s,size,1,m)==1) { sr=0; if( strcmp (s.name,sname)==0) { // printf(" Enter new name,Acc.no,Balance"); // scanf("%s%d%f",s.name,&s.rollno,&s.percent); // fseek(m,-size,SEEK_CUR); // fwrite(&s,size,1,m); printf(" Record found"); printf(" Name Acc.No Ammount Due "); printf(" %30s%12d%23.2f",s.name,s.accno,s.balance); sr=1; getch(); break; } } if(sr==0) printf(" Record "%s" is not found",sname); printf(" Search more records (Y/N)"); fflush(stdin); mrec=getche(); } clearviewport(); break; case 6: fclose(m); exit(); } showmouseptr(); } } displaymenu(char **menu,int count,int x1,int y1) { int i,h; h=textheight(menu[0]); for(i=0;i<count;i++) outtextxy(x1,y1+i*(h+5),menu[i]); } savemenu (char **menu,char **buffer,int width,int count,int x1,int y1) { int i,x2,yy1,yy2,area,h; h=textheight(menu[0]); for(i=0;i<count;i++) { x2=x1+width; yy1=y1+i*(h+5); yy2=y1+(i+1)*(h+5); area=imagesize(x1,yy1,x2,yy2); buffer[i]=malloc(area); getimage(x1,yy1,x2,yy2,buffer[i]); } } getresponse(char **menu,char **buffer,int width,int count,int x1,int y1) { int choice=1,prevchoice=0,x,y,x2,y2,button; int in,i,h; h=textheight(menu[0]); y2=y1+count*(h+5); x2=x1+width; rectangle(x1-5,y1-5,x2+5,y2+5); while(1) { getmousepos(&button,&x,&y); if (x>=x1&&x<=x2&&y>=y1&&y<=y2) { in=1; for(i=1;i<=count;i++) { if(y<=y1+i*(h+5)) { choice=i; break; } } if(prevchoice!=choice) { hidemouseptr(); highlight(buffer,choice,h,x1,y1); if(prevchoice) dehighlight(buffer,prevchoice,h,x1,y1); prevchoice=choice; showmouseptr(); } if((button & 1)==1) { while ((button & 1)==1) getmousepos(&button,&x,&y); if(x>=x1&&x<=x2&&y>=y1&&y<=y2) return(choice); } } else { if( in ==1) { in=0; prevchoice=0; hidemouseptr(); dehighlight(buffer,choice,h,x1,y1); showmouseptr(); } } } } highlight(char **buffer,int ch,int h,int x1,int y1) { putimage(x1,y1+(ch-1)*(h+5),buffer[ch-1],NOT_PUT); } dehighlight(char **buffer,int ch,int h,int x1,int y1) { putimage(x1,y1+(ch-1)*(h+5),buffer[ch-1],COPY_PUT); } /* initmouse */ initmouse() { i.x.ax=0; int86 (0x33,&i,&o); return(o.x.ax); } /* displays mouse pointer */ showmouseptr() { i.x.ax=1; int86(0x33,&i,&o); } hidemouseptr() { i.x.ax=2; int86(0x33,&i,&o); } /*gets mouse coordinates and button status*/ getmousepos(int *button,int *x,int *y) { i.x.ax=3; int86(0x33,&i,&o); *button=o.x.bx; *x=o.x.cx; *y=o.x.dx; } movemouseptr(int *x,int *y) { i.x.ax=4; int86(0x33,&i,&o); o.x.cx=*x; o.x.dx=*y; return 0; }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi դ ? ??
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=747


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review