123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
SLAM BOOK ,YOU CAN ADD UR FRIENDS BIODATA.

--------------------------------------------------------------------------------

Description : In this project binary file concepts ,graphics fucntions are used. mouse pointer is used. I AM SURE YOU WILL ENJOY BY USING MY SLAM BOOK AS MUCH I AM.

#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<process.h>
#include<stdio.h>
#include<string.h>
union REGS i,o;
void main()
{
int driver,mode,x,y,but,z; //intialitions of all variables
and
functions
driver = DETECT;
int initmouse(); // to load mouse driver
int resmptr(int p,int q,int r,int s); //restric mouse pointer
within
boundry
int showmptr(); // shows mouse pointer
int getmpos(int *t,int *u, int *v); // captures the current
position of mouse pointer
initgraph(&driver, &mode, "C:\tc\bgi"); //initialize graphics
mode
nare :
setcolor(YELLOW);
outtextxy(250,10,"MY SLAM BOOK");
setcolor(GREEN);
outtextxy(70,70,"I'm sure you'll enjoy filling my slam book as
much
as");
outtextxy(80,80,"I will enjoy reading about you later.");
setcolor(LIGHTGREEN);
rectangle(30,30,635,460);
rectangle(200,100,380,115);
outtextxy(210,105," 1.Add Records");
rectangle(200,120,380,135);
outtextxy(210,125," 2.List Records");
rectangle(200,140,380,155);
outtextxy(210,145," 3.Modify Records");
rectangle(200,160,380,175);
outtextxy(210,165," 4.Delete Records");
rectangle(200,180,300,195);
outtextxy(210,185," 0.Exit");
if(initmouse() == 0)
{ // load mouse
driver if not
closegraph(); // exit the program
restorecrtmode();
printf("
Mouse driver is not loaded");
exit(1);
}
showmptr();
resmptr(30,30,635,460);
setcolor(RED);
outtextxy(70,310,"# Press Add Records button to add a record");
outtextxy(70,330,"# Press List Records button to list records");
outtextxy(70,350,"# Press Modify Records button to modify any
record");
outtextxy(70,370,"# Press Delete Records button to delete
record");
setcolor(13);
setcolor(YELLOW);
outtextxy(200,440,"Press any key to exit program");
FILE *fp,*ft;
char another,choice,ch;
struct frien
{
char urname[40];
char emailid[40];
long int mobno;
};
struct frien f;

char friname[40];
long int recsize;

fp=fopen("FRE.DAT","rb+");
if(fp==NULL)
{
fp=fopen("FRE.DAT","wr+");
if(fp==NULL)
{
puts("Cannot open file");
exit(0);
}
}
recsize=sizeof(f);
while(!kbhit()) // loop until
any
key is pressed
{
getmpos(&but,&x,&y); // capture
current
pointer position when click event happens
if(x>=200 && x<=380 && y>=100 && y<=115 && (but & 1) == 1) //
and
switch to that if loop
{
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
gotoxy(100,100);
printf("
HELLO FRIEND ");
fseek(fp,0,SEEK_END);
another='y';
while(another=='y')
{
printf("

Enter ur Name:-");
scanf("%s",f.urname);
printf("

Enter ur Email ID:-");
scanf("%s",f.emailid);
printf("

Enter ur Mobileno:-");
scanf("%ld",&f.mobno);
fwrite(&f,recsize,1,fp);
printf("

1 record has been added successfully");
printf("

Add another Record (y/n)");
outtextxy(150,380,"PRESS n TO GO TO MAIN SCREEN");
fflush(stdin);
another=getche();
if(another=='n')
{
fflush(stdin);
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
goto nare;
}
}

} //first if ends
else if(x>=200 && x<=380 && y>=120 && y<=135 && (but & 1) == 1)
{
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
outtextxy(100,370,"THESE ARE MY BEST FRIENDS,I LOVE THEM VERY
MUCH");
outtextxy(100,390,"PRESS n TO GO TO MAIN SCREEN");
fseek(fp,0,SEEK_SET);
printf("NAME EMAILID MOBILENO ");
while(fread(&f,recsize,1,fp)==1)
{
printf("<BR>);
printf("%s %s %ld ",f.urname,f.emailid,f.mobno);
printf("<BR>);
}
if(getche()=='n')
{
fflush(stdin);
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
goto nare;
}

} //second if ends

else if(x>=200 && x<=380 && y>=140 && y<=155 && (but & 1) == 1)
{

clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
setcolor(YELLOW);
printf("HELLO");
another='y',ch='y';
while(another=='y')
{
printf("
Enter name of friend to modify:-");
scanf("%s",friname);
if(strcmp(f.urname,friname)==0)
{
printf("

U r stored in my book");
printf("

Are you sure you want to modify the %s
document",friname);
printf("
Then press (y/n)");
fflush(stdin);
ch=getche();
if(ch=='y')
{
rewind(fp);
while(fread(&f,recsize,1,fp)==1)
{
if(strcmp(f.urname,friname)==0)
{
printf("

Enter ur Name:-");
scanf("%s",f.urname);
printf("

Enter ur Email ID:-");
scanf("%s",f.emailid);
printf("

Enter ur Mobileno:-");
scanf("%d",&f.mobno);
fseek(fp,-recsize,SEEK_CUR);
fwrite(&f,recsize,1,fp);
printf("

1 record has been modified successfully");
printf("

Modify another Record(y/n)");
break;
}
}
}
}
else
{
printf("

Sorry ! U r not in my book");
printf("

U can now add urself");
}
outtextxy(100,380,"PRESS n TO GO TO MAIN SCREEN");
if(getche()=='n')
{
fflush(stdin);
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
goto nare;
}
fflush(stdin);
another=getche();
}
}// third if ends

else if(x>=200 && x<=380 && y>=160 && y<=175 && (but & 1) == 1)
{
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
another='y';
while(another=='y')
{
printf("

Enter name of friend to delete:-");
scanf("%s",friname);
if(strcmp(f.urname,friname)!=0)
{
printf("
Sorry ! Ur record is not available

Check the name correctly");

goto sid;
}
ft=fopen("TEMP.DAT","wb");
rewind(fp);
while(fread(&f,recsize,1,fp)==1)
{
if(strcmp(f.urname,friname)!=0)
fwrite(&f,recsize,1,ft);
}
fclose(fp);
fclose(ft);
printf("

Are you sure,then press 'y'");
if(getche()=='y')
{
remove("FRE.DAT");
rename("TEMP.DAT","FRE.DAT");
}
setcolor(WHITE);
outtextxy(40,370,"THE RECORD IS DELETING");
rectangle(40,380,580,405);
for(z=40;z<=580;z++)
{
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
rectangle(40,380,z,405);
delay(10);
setfillstyle(SOLID_FILL,BLUE);
floodfill(42,392,WHITE);
}
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
sid :
printf("

Delete another Record(y/n)");
fflush(stdin);
another=getche();
setcolor(YELLOW);
outtextxy(100,380,"PRESS n TO GO TO MAIN SCREEN");
if(another=='n')
{
fflush(stdin);
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
goto nare;
}
fp=fopen("FRE.DAT","rb+");

}

}// forth if ends

else if(x>=200 && x<=300 && y>=180 && y<=195 && (but & 1) == 1)
{
clrscr();
setfillstyle(SOLID_FILL,BLACK);
floodfill(0,0,BLACK);
setcolor(YELLOW);
outtextxy(120,100,"THANKING YOU FOR USING MY SLAM BOOK");
getch();
fclose(fp);
exit(0);
}// fifth if ends

} // while loop ends
} // main ends

getmpos(int *but,int *x,int *y)
{
i.x.ax = 3;
int86(0x33,&i,&o);
*but = o.x.bx;
*x = o.x.cx;
*y = o.x.dx;
}
initmouse()
{
i.x.ax = 0;
int86(0x33,&i,&o);
return(o.x.ax);
}
showmptr()
{
i.x.ax = 1;
int86(0x33,&i,&o);
}
resmptr(int a,int b,int c,int d)
{
i.x.ax = 7;
i.x.cx = a;
i.x.dx = c;
int86(0x33,&i,&o);
i.x.ax = 8;
i.x.cx = b;
i.x.dx = d;
int86(0x33,&i,&o);
}
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG