Sunday, 23 December 2012

C++ Project on Telephone Directory



Telephone Directory


#include<iostream .h>
#include<fstream .h>
#include<iomanip .h>
#include<string .h>
#include<stdlib .h>
#include<conio .h>
#include<stdio .h>
#include<iomanip .h>
#include<graphics .h>
#include<dos .h>
class stud

{

public:

char name[20];

char address[20];

unsigned int ph_no;

void get(void);

void show(void);

void modify(void);

};

void stud::get(void)

{

int i=0;

cout<”;

cin.get(name[i]);

while(name[i]!=’n’)

{

i=i+1;

cin.get(name[i]);

}

cin.getline(name,20,’n’);

cout<”;

cin.getline(address,20,’n’);

fflush(stdin);

cout<t”;

cin>>ph_no;

fflush(stdin);

}

void stud::show(void)

{

cout<

cout<}

void main()

{

int gdriver = DETECT, gmode, errorcode;

int x,y;

int midx,midy;

/* initialize graphics and local variables */

initgraph(&gdriver, &gmode, “”);

/* read result of initialization */

errorcode = graphresult();

if (errorcode != grOk) /* an error occurred */

{

printf(“Graphics error: %sn”, grapherrormsg(errorcode));

printf(“Press any key to halt:”);

getch();

exit(1); /* terminate with an error code */

closegraph();

}

y:

char*pass=”RPV”;

char*ppass;

gotoxy(25,8);

int size=7;

settextstyle(7,0,size);

setbkcolor(BLUE);

setcolor(WHITE);

outtextxy(180,50,”WELCOME” );

setcolor(WHITE);

outtextxy(250,200,”TO”);

settextstyle(8,0,5);

setfillstyle(1,DARKGRAY);

setcolor(WHITE);

outtextxy(60,350,”nnTELEPHONE DIRECTORY”);

getch();

clearviewport();

settextstyle(3,0,4);

settextstyle(7,0,4);

getch();

clearviewport();

g:

ppass=getpass(“ENTER THE PASSWORD::”);

if(strcmpi(pass,ppass)!=0)

{

cout< PRESS ANY KEY 1 TO 6 ” );

settextstyle(TRIPLEX_FONT ,HORIZ_DIR,4);

outtextxy(220,50,”nn1. TO ADD ” );

setcolor(BLUE);

settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);

outtextxy(220,100,”nn2. TO SHOW ” );

setcolor(BLUE);

settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);

outtextxy(220,150,”nn3. TO SEARCH ” );

setcolor(BLUE);

settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);

outtextxy(220,200,”4.nn TO MODIFY ” );

setcolor(BLUE);

settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);

outtextxy(220,250,”nnn5. TO DELETE ” );

setcolor(BLUE);

settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);

outtextxy(220,300,”nnn6. TO EXIT ” );

settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);

outtextxy(220,350,” Enter the choice ->”);

gotoxy(62,23);

cin>>ch;

switch(ch)

{

case 1: //responsible for addition of record

{

clrscr();

fstream f;

f.open(“rec”,ios::in|ios::out|ios::ate|ios::app|ios::binary);

char ans;

s.get();

f.write((char *)&s,sizeof(s));

clrscr();

outtextxy(250,360, ” Do you want to continue:- “);

ans=getche();

if(ans==’Y’ || ans==’y'){goto z;}

f.close();

break;

}

case 2: // will show all the contents of the file

{

clrscr();

cout<
fstream f;

f.open(“rec”,ios::in|ios::out|ios::ate|ios::app|ios::binary);

f.seekg(0);

int ctr=0;

while(f.read((char *)&s,sizeof(s)) )

{

ctr=ctr+1;

if(ctr==8) {getchar(); clrscr();ctr=0;}

s.show();

if(f.eof()==1)

{break;}

}

f.close();

outtextxy(240,350, ” Do you want to continue :-”);

char ans;

ans=getche();

if(ans==’y'|| ans==’Y'){

closegraph();

goto z;}else{exit(1);}

}

case 3: // search

{

gotoxy(60,25);

clearviewport();

rectangle(10,10,630,470);

setbkcolor(DARKGRAY);

textbackground(3);

textcolor(5);

clrscr();

char ans;

ifstream f;

stud s;

char name[20];

char address[20];

unsigned int ph_no;

f.open(“rec”,ios::in|ios::binary);

cout<
getchar();

closegraph();

exit(1);

}

default:

goto z;

}

}

}

}


Please do +1, Like, Share, Send, Tweet, Stumble Upon this page to support us.

0 comments:

Post a Comment

 

SCROLL TO TOP