An important IT project for students. A program on electronic dairy that can be efficiently used as a telephone directory.
MADE BY:-
DIVYA BATRA
XII-A
**************************************************************************
/
/*************************************************************************
HEADER FILE FUNCTIONS
process.h exit()
dos.h delay()
conio.h clrscr()
gotoxy()
textbackground()
textcolor()
getch()
stdio.h gets()
string.h strcmp()
fstream.h open()
close()
**************************************************************************
*/
#include<process.h>
#include<dos.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<string.h>
//************************************************************************
**
// Structure of telephone directory
//************************************************************************
**
struct tel
{
char telno[20];
char name[20];
char add[20];
}s;
//************************************************************************
**
// Functions
//************************************************************************
**
void display(void);
void enquiryt(void);
void enquiryn(void);
void delet(void);
void option(void);
void des(void);
void box_fill(void);
//************************************************************************
**
// Main Function
//************************************************************************
**
main()
{
clrscr();
textbackground(3);
textcolor(4);
for (int i=1;i<24;i++)
{
clrscr();
gotoxy(i,1);
cprintf(” ***Telephone Directory*** “);
delay(100);
}
for (int o=2;o<7;o++)
{
clrscr();
gotoxy(23,o);
cout<<” ***Telephone Directory*** “;
delay(100);
}
delay(1000);
gotoxy(33,9);
cout<<” Made By:- “;
delay (1000);
gotoxy(31,11);
cout<<” Divya Batra “;
delay(1000);
gotoxy(32,13);
cout<<” Class XII-A “;
delay(1000);
gotoxy(22,15);
cout<<” The Heritage School Vasant Kunj “;
delay(3000);
getch();
option();
}
//************************************************************************
**
// Main Menu
//************************************************************************
**
void option(void)
{
clrscr();
int j;
box_fill();
gotoxy(30,3);
cout<<“***** MAIN MENU *****”;
gotoxy(15,6);
cout<<” 1. Add Records. “;
gotoxy(15,8);
cout<<” 2. Get enquiry from telephone number. “;
gotoxy(15,10);
cout<<” 3. Get enquiry from names of person. “;
gotoxy(15,12);
cout<<” 4. Delete Records. “;
gotoxy(15,14);
cout<<” 5. Exit. “;
gotoxy(15,16);
cout<<” Enter your choice:”;
cin>>j;
switch(j)
{
case 1:
display();
break;
case 2:
enquiryt();
break;
case 3:
enquiryn();
break;
case 4:
delet();
break;
default:
exit(1);
}
}
void des(void)
{
gotoxy(10,23);
cout<<”
Press any key to see main menu again…..
“;
getch();
option();
}
//************************************************************************
**
// Function to create file of people
//************************************************************************
**
void display(void)
{
clrscr();
char ans;
ans=’y’;
ofstream fp;
fp.open(“Tel.dat”,ios::app);
do
{
box_fill();
// char ch=cin.get();
gotoxy(13,6);
cout<<” Telephone number:”;
gets(s.telno);
gotoxy(13,8);
cout<<” Name of Person:”;
gets(s.name);
gotoxy(13,10);
cout<<” Address:”;
cin>>s.add;
fp.write((char *)&s,sizeof(tel));
gotoxy(13,12);
cout<<” Do you want to Continue:”;
cin>>ans;
}
while(ans==’y’);
fp.close();
des();
}
//************************************************************************
**
// Function to get enquiry by telephone from main file
//************************************************************************
**
void enquiryt(void)
{
char v[20];
clrscr();
ifstream fp5;
fp5.open(“Tel.dat”);
box_fill();
gotoxy(15,10);
cout<<” Enter the desire telephone number:”;
cin>>v;
while(fp5)
{
fp5.read((char *)&s,sizeof(tel));
if(!fp5)
break;
if(strcmp(s.telno,v)==0)
{
gotoxy(15,14);
cout<<” Telephone Number: “<<s.telno;
gotoxy(15,16);
cout<<” Name: “<<s.name;
gotoxy(15,18);
cout<<” Address: “<<s.add;
}
}
fp5.close();
des();
}
//************************************************************************
**
// Function to get enquiry by name from main file
//************************************************************************
**
void enquiryn(void)
{
char a[20];
clrscr();
ifstream fp5;
fp5.open(“Tel.dat”);
box_fill();
gotoxy(15,10);
cout<<” Enter the name:”;
cin>>a;
while(fp5)
{
fp5.read((char *)&s,sizeof(tel));
if(!fp5)
break;
if(strcmp(a,s.name)==0)
{
gotoxy(15,14);
cout<<” Telephone Number: “<<s.telno;
gotoxy(15,16);
cout<<” Name: “<<s.name;
gotoxy(15,18);
cout<<” Address: “<<s.add;
}
}
fp5.close();
des();
}
//************************************************************************
**
// Function to delete any record from main file
//************************************************************************
**
void delet(void)
{
char v[20];
clrscr();
ifstream fp;
fp.open(“Tel.dat”);
ofstream fp1;
fp1.open(“Tel1.dat”);
while(fp)
{
fp.read((char *)&s,sizeof(tel));
if(!fp)
break;
fp1.write((char *)&s,sizeof(tel));
}
fp.close();
fp1.close();
ifstream afile;
ofstream bfile;
afile.open(“Tel1.dat”);
bfile.open(“Tel.dat”);
box_fill();
gotoxy(14,10);
cout<<” Enter the telephone number to be deleted: “;
cin>>v;
while(afile)
{
afile.read((char *)&s,sizeof(tel));
if(!afile)
break;
if(strcmp(s.telno,v)!=0)
{
bfile.write((char *)&s,sizeof(tel));
}
}
bfile.close();
afile.close();
des();
}
//************************************************************************
**
// Procedure for creating box for menues and prompts
//************************************************************************
**
void box_fill(void)
{
int xr,xc;
int la,ra;
gotoxy(10,2);
for(xr=1;xr<=60;xr++)
cout<<“*”;
xc=3;
for(la=1;la<=19;la++)
{
gotoxy(10,xc);
cout<<“()”;
gotoxy(69,xc);
cout<<“()”;
xc++;
}
gotoxy(10,22);
for(xr=1;xr<=60;xr++)
cout<<“*”;
}