Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Project

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 60

TELEPHONE

DIRECTORY SYSTEM

Project work submitted to the Chellappan Vidya Mandir


International School in partial fulfillment of the
requirements for the award of

HIGHER SECONDARY – SECOND YEAR

Submitted by
SUBHASHREE.R

Register Number:

Under the guidance of

MRS. K. SIVACHITRA MBA, M.Sc., B.Ed


PG (Assistant) in COMPUTER SCIENCE

O.Siruvayal Road, Peyanpatti,


Karaikudi - 630 208.
2019-2020
1
BONAFIDE CERTIFICATE
This is to certify that the project work was done under the guidance
and this work entitled as “TELEPHONE DIRECTORY SYSTEM”
submitted by SUBHASHREE.R to Chellappan Vidya Mandir
International School in partial fulfillment of the requirements for the
award of Higher Secondary- Second year during the year 2019-2020.
Also certified that this work has not been submitted in full or in part
to this school or any other institution.

PRINCIPAL GUIDE
U.GANESH KUMAR K.SIVACHITRA
M.A., M.Ed., M.Phil., MBA, M.Sc., B.Ed.,
Chellappan Vidya Mandir Chellappan Vidya Mandir
International School International School
Karaikudi Karaikudi

EXTERNAL EXAMINER

2
DECLARATION

I hereby declare that the dissertation entitled “TELEPHONE


DIRECTORY SYSTEM” is an original work done by me
and that it has not previously formed the basis for the award of
any higher degrees.

Place: CHELLAPPAN VIDYA MANDIR INTERNATIONAL


SCHOOL

Date:

SUBH SHREE.R

3
ACKNOWLEDGEMENT

I express my deepest sense of gratitude to


Mrs. K.SIVACHITRA MBA, M.Sc., B.Ed., Guide, for her
valuable guidance and for her constant encouragement with
timely advice throughout this project work.
I wish to express my sincere thanks to
Mr. U. Ganesh Kumar, M.Sc., M.Ed., M.Phil., Principal,
Chellappan Vidya Mandir International School, Karaikudi for
his kind encouragement in completing this project work.
I also extend my sincere thanks to the faculty
members of this institution for their whole hearted support for
this project work.
I wish to thank my parents, friends and well wishers
for their timely help to complete this project.
I thank CBSE for providing me with an opportunity to
undertake this project.
Finally I thank the almighty, the beloved who lit
education in my life.

4
CONTENTS

5
CONTENTS
S.NO TITLE PAGE
NO.
1 ABSTRACT 7
2 INTRODUCTION 9
3 SYSTEM ENVIRONMENT 12
2.1. Hardware specifications 13
2.2. Software specifications 13
4 C++ Overview 15
2.3. OOP’s Concept 16
2.4.1. Class and Object 18
2.4.2. Inheritance 20
2.4.3. Function Overloading 21
2.4.4. Data Encapsulation 22
2.4.5. Data Abstraction 23
2.4.6. Data File and Streams 24
5 STUDY AND ANALYSIS OF 28
TELEPHONE DIRECTORY
SYSTEM
6 DESIGN AND DEVELOPMENT OF 35
TELEPHONE DIRECTORY SYSTEM
7 CONCLUSION 43
8 BIBLIOGRAPHY 45
9 SOURCE CODE 47

6
ABSTRACT

7
ABSTRACT

A Project entitled “Telephone Directory” is used to maintain


the phone numbers of many users in a system.

In this system we can add the new entries, view all the
available entries, modify the specified record and delete a
particular entry.

Here we maintain all of our data in a MS- Acces file. On that


file only we can add new entry, modify entry and delete a
particular entry.

Before this Telephone Directory system users maintain there


required phone numbers in a book. There may be a chance to
loss of book. It is a time consuming process to identify a
particular number.

In order to eliminate the drawbacks of the existing system, a


system has been developed due to which the person need not
spend much time in identify a phone number and instead
database is built that takes care of every transaction thereby
reducing the burden on customer.

8
INTRODUCTION

9
INTRODUCTION

This system is developed using the general need required by


the user while using the phone directory book. In order to
keep updated the phone book directory, the admin will have
the authority to add and delete as well as modify the existing
records within the phone book directory.

The users of the directory will only have the authority to


search any particular record and listing details of all available
records. Admin will have the authority to perform various
operations such as add customer records, search any particular
record, delete record, modify existing record etc.

To provide the search result within short interval of time


optimized search algorithm code has been used which will
able to provide the results within seconds. To make all
operations as easier as possible, user friendly approach has
been taken into account by which users have to only give their
answer during final confirmation to make their operations
successful.

10
The background processing system will take care of all
processing task and maintain data integrity in order to reduce
the redundancy of data. For searching operation, users will
able to get any particular record using their contact or phone
number but the only condition is that, customers record must
be available within the file system. If no such record will be
available, proper error message will be displayed as per user
input provided to the system.

11
SYSTEM
ENVIRONMENT

12
SYSTEM ENVIRONMENT

2.1 HARDWARE SPECIFICATION


 System : Pentium(R) Dual-core CPU E5700
3.00GHz

 Ram : 1.00 GB

 System Type : 32 bit operating system

2.2 SOFTWARE SPECIFICATION

 Operating System : Windows 7

 Coding Language : C++

13
C++
PROGRAMMING

14
2.3 Overview of C++

C++ is a multi-paradigm programming language that supports


object-oriented programming (OOP), created by BJarne
Stroustrup in 1983 at Bell Labs, C++ is an extension
(superset) of the programs written in C.

C++ is a statically typed, compiled, general purpose, case-


sensitive, free-form programming language that supports
procedural, object-oriented and generic programming.

Note : A programming language is said to use static typing


when type checking is performed during compile-time as
opposed to run time.

2.4 Object-Oriented Programming


C++ supports object-oriented programming (OOP), with four
major principles of object-oriented development:
 Abstraction
 Encapsulation
 Inheritance
 Polymorphism

15
Features of Object Oriented C++
 The main focus remains on data rather than procedures.
 Object oriented programs are segmented into parts called
objects.
 Data structures are designed to categorize the objects.
 Data member and functions are tied together as a data
structure.
 Data can be hidden and cannot be accessed by external
functions using access specifier.
 Objects can communicate among themselves using
functions.

 New data and functions can be easily added anywhere


within a program whenever required.
 Since this is an object-oriented programming language, it
follows bottom up approach, i.e. the execution of codes
starts from the main which resides at the lower section
and then based on the member function call the working
is done from the classes.
 Object oriented approach is a recent concept among
programming paradigms and has various fields of
progress. Object oriented programming is a technique
that provides a way of modularizing programs by
creating memory area as a partition for both data and
functions that can further be used as a template to create
copies of modules on demand.

16
Standard Libraries in C++
C++ standard library was created after many years and it has
three important parts:
 C++ core language provides all the building blocks
including data types, variables and literals etc.
 The C++ Standard Library has rich set of methods to
manipulate files and strings.
 The STL(Standard Template Library) provides a rich set
of template classes for manipulating data structures.
ANSI Standard for C++
ANSI stands for American National Standard Institute & the
ANSI standard began an attempt to ensure that C++ codes
become portable – that code written for Microsoft’s compiler
will compile without having any errors can run on compilers
of MAC or Linux or any other compiler. So, all major C++
compilers support the ANSI Standard.

LEARNING C++:

The most important thing to do when learning C++ is to focus


on concepts and not get lost in language technical details. The
purpose of learning a programming language is to become a
better programmer: that is to become more effective designing
and implementing new systems and at maintaining old ones.
C++ supports a variety of programming styles. You can write
in the style of FORTRAN, C, Smalltalk etc…, in any
language. Each style can achieve its aims effectively while
maintaining runtime and space efficiency.

17
Uses of C++:
C++ is used by programmers to create computer software. It is
used to create general systems software, drivers for various
computer devices, software for servers and software for
specific applications and also widely used in the creation of
video games.
C++ is used by many programmers of different types and
coming from different fields. C++ is mostly used to
write device driver programs,
System software and applications that depend on
direct hardware manipulation under real time constraints. It is
also used to teach the basics of object oriented features
because it is simple and is also used in the fields of research.
Also, many primary user interfaces and system files of
Windows and Macintosh are written using C++. So, C++ is
really a popular, strong and frequently used programming
language of this modern programming era.

2.4.1. CLASS AND OBJECT


The main purpose of C++ programming is to add object
orientation to the C programming language and classes are the
central feature of C++ that supports object-oriented
programming and are often called user-defined types.
A class is used to specify the form of an object and it
combines data representation and methods for manipulating
that data into one neat package. The data and functions within
a class are called members of the class.

18
C++ CLASS DEFINITIONS
When you define a class, you define a blueprint for a data
type. This doesn’t actually define any data, but it does define
what the class name means, that is, what an object of the class
will consist of and what operations can be performed on such
an object.
A class definition starts with the keyword class followed
by the class name, and the class body, enclosed by a pair of
curly braces. A class definition must be followed either by a
semicolon or a list of declarations. For example, we defined
the Box data type using the keyword class as follows:

Class Box
{
Public:
double length; // Length of a box
double breadth; //Breadth of a box
double height; //Height of a box
};
The keyword public determines the access attributes of the
members of the class that follow it. A public member can be
accessed from outside the class anywhere within the scope of
the object class as private or protected which we will discuss
in a sub-section.

19
DEFINE C++ OBJECTS

A class provides the blueprints for objects, so basically


an object is created from class. We declare objects of a class
with exactly the same sort of declaration that we declare
variables of basic types.
Following statements declare two objects of class Box:

Box Box1; //Declare Box1 of type Box


Box Box2; //Declare Box2 of type Box

Both of the objects Box1 and Box2 will have their own copy
of data members.

2.4.2. INHERITANCE

One of the most important concepts in object-oriented


programming is that of inheritance. Inheritance allows us to
define a class in terms of another class, which makes it easier
to create and maintain an application. This also provides an
opportunity to reuse the code functionality and fast
implementation time.
When creating a class, instead of writing completely new
data members and member functions, the programmer can
designate that the new class should inherit the members of an
existing class. This existing class is called the base class, and
the new class is referred to as the derived class.
The idea of inheritance implements the ‘is a’ relationship.
For example, mammal IS-A animal, dog IS-A mammal hence
dog IS-A animal as well and so on.

20
Base and Derived Classes
A class can be derived from more than one class, which
means it can inherit data and functions from multiple base
classes. To define a derived class, we use a class derivation
list to specify the base class (es). A class derivation list
names one or more base classes and has the form −
class derived-class: access-specifier base-class
Where access-specifier is one of public,
protected, or private, and base-class is the name of a
previously defined class. If the access-specifier is not used,
then it is private by default.

2.4.3 FUNCTION OVERLOADING


C++ allows you to specify more than one definition for
a function name or an operator in the same scope, which is
called function overloading and operator
overloading respectively.
An overloaded declaration is a declaration that is declared
with the same name as a previously declared declaration in
the same scope, except that both declarations have different
arguments and obviously different definition
(implementation).
When you call an overloaded function or operator, the
compiler determines the most appropriate definition to use,
by comparing the argument types you have used to call the
function or operator with the parameter types specified in the
definitions. The process of selecting the most appropriate
overloaded function or operator is called overload
resolution.

21
Function Overloading in C++

You can have multiple definitions for the same function name
in the same scope. The definition of the function must differ
from each other by the types and/or the number of arguments
in the argument list. You cannot overload function
declarations that differ only by return type.

2.4.4. DATA ENCAPSULATION

All C++ programs are composed of the following two


fundamental elements −
 Program statements (code) − This is the part of a
program that performs actions and they are called
functions.
 Program data − The data is the information of the
program which gets affected by the program functions.
Encapsulation is an Object Oriented Programming concept
that binds together the data and functions that manipulate the
data, and that keeps both safe from outside interference and
misuse. Data encapsulation led to the important OOP concept
of data hiding.
Data encapsulation is a mechanism of bundling the data,
and the functions that use them and data abstraction is a
mechanism of exposing only the interfaces and hiding the
implementation details from the user.

22
C++ supports the properties of encapsulation and data hiding
through the creation of user-defined types, called classes. We
already have studied that a class can contain private,
protected and public members. By default, all items defined
in a class are private.
2.4.5 DATA ABSTRACTION

Data abstraction refers to providing only essential


information to the outside world and hiding their background
details, i.e., to represent the needed information in program
without presenting the details.
Data abstraction is a programming (and design) technique
that relies on the separation of interface and implementation.
Let's take one real life example of a TV, which you can turn
on and off, change the channel, adjust the volume, and add
external components such as speakers, VCRs, and DVD
players, BUT you do not know its internal details, that is, you
do not know how it receives signals over the air or through a
cable, how it translates them, and finally displays them on the
screen.
Thus, we can say a television clearly separates its internal
implementation from its external interface and you can play
with its interfaces like the power button, channel changer,
and volume control without having zero knowledge of its
internals.
In C++, a class provides great level of data abstraction.
They provide sufficient public methods to the outside world
to play with the functionality of the object and to manipulate
object data, i.e., state without actually knowing how class has
been implemented internally.
23
For example, your program can make a call to
the sort() function without knowing what algorithm the
function actually uses to sort the given values. In fact, the
underlying implementation of the sorting functionality could
change between releases of the library, and as long as the
interface stays the same, your function call will still work.

2.4.6. DATA FILE AND STREAMS

The standard C++ library called fstream, which defines three


new data types −
Sr.No Data Type & Description

1 ofstream
This data type represents the output file stream and
is used to create files and to write information to
files.

2 ifstream
This data type represents the input file stream and is
used to read information from files.

3 fstream
This data type represents the file stream generally,
and has the capabilities of both ofstream and
ifstream which means it can create files, write
information to files, and read information from files.
To perform file processing in C++, header files <iostream>
and <fstream> must be included in your C++ source file.
24
OPENING A FILE
A file must be opened before you can read from it or write to
it. Either ofstream or fstream object may be used to open a
file for writing. And ifstream object is used to open a file for
reading purpose only.
Following is the standard syntax for open() function, which is
a member of fstream, ifstream, and ofstream objects.
void open(const char *filename, ios::openmode mode);
Here, the first argument specifies the name and location of
the file to be opened and the second argument of
the open() member function defines the mode in which the
file should be opened.
S.No Mode Flag & Description

1 ios::app
Append mode. All output to that file to be appended
to the end.

2 ios::ate
Open a file for output and move the read/write
control to the end of the file.

3 ios::in
Open a file for reading.

4 ios::out
Open a file for writing.

25
5 ios::trunk
If the file already exists, its contents will be
truncated before opening the file.
You can combine two or more of these values by ORing
them together. For example if you want to open a file in write
mode and want to truncate it in case that already exists,
following will be the syntax −
ofstream outfile;
outfile.open("file.dat", ios::out | ios::trunc );
Similar way, you can open a file for reading and writing
purpose as follows −
fstream afile;
afile.open("file.dat", ios::out | ios::in );

CLOSING A FILE
When a C++ program terminates it automatically flushes all
the streams, release all the allocated memory and close all the
opened files. But it is always a good practice that a
programmer should close all the opened files before program
termination.
Following is the standard syntax for close() function, which
is a member of fstream, ifstream, and ofstream objects.
void close();

WRITING TO A FILE
While doing C++ programming, you write information to a
file from your program using the stream insertion operator
(<<) just as you use that operator to output information to the
26
screen. The only difference is that you use
an ofstream or fstream object instead of the cout object.

READING FROM A FILE

You read information from a file into your program using the
stream extraction operator (>>) just as you use that operator
to input information from the keyboard. The only difference
is that you use an ifstream or fstream object instead of
the cin object.

27
STUDY AND ANALYSIS OF
TELEPHONE DIRECTORY
SYSTEM

28
SYNOPSIS

Purpose:

The purpose of the system, which has been developed, is to


allow an end user to interact with the Telephone Directory
system which provides some basic features such as adding
new record information, modifying, viewing and deleting
entries. This will also save a lot of time.

Scope:

 Users save the phone numbers along with their


names
 Modify the names and phone numbers
 Deleting the contact numbers
 Viewing all contact numbers one after another

29
OBJECTIVES

We are determined to design a system which is intended in


saving name and number of desired persons. The main
objective of telephone directory is to add, search, edit and
delete various contacts.

APPLICANTS

Telephone directory has been frequently in use in our daily


life. Wecommonly see telephone directory installed in PSTN
telephone sets, mobile phone etc. Telephone Directory
application provides the ability to search, view, and manage
entries in a directory. Mobile Directory application should
allow any subscriber with any type of mobile device that
supports GPRS to instantly search telephone contact number
of any individual . The search result data loads directly to the
mobile screen and gives the user option :-
CALL,
SAVE,
VIEW,
SEND TO FRND or
DISCARD. Mobile Directory eliminates the need to call any
other call center.

30
GOALS OF A NEW SYSTEM

1. Will be readily available.


2. To avoid errors inherent in manual paper work.
3. To improve management of permanent and updated
information i.e.,
4. Databases by providing facilities to edit this information,
manipulate it
And finally retrieve this information as efficiently as
possible.
5. To reduce paper work.

31
SOFTWARE SPECIFICATION

C-PROGRAMMING

The C programming is a popular and widely used high level


programming language for creating computer programs.
Programmers around the world embrace C because it gives
maximum concomponents used while developing program. c.
Proteus is mainly used in simulation, a simple model of ckt
was created and with particular program it was loaded to view
output.

C++- PROGRAMMING

Managed extensions for c++ and attributed programming are


just some of the enhancements made to the c++ language.
Managed extensions simplify the task of migrating existing
c++ applications to the new.NET framework. Attributes, like
c++ keywords, are used in your source files and interpreted by
the compiler.

32
PROBLEM DEFINITION

Existing System

Before this Telephone Directory system users maintain there


required phone numbers in a book. There may be a chance to
loss of book. It is a time consuming process to identify a
particular number. If the book is lost by us then we are lost the
all contact numbers. Then once again we are gathering those
all persons details is very difficult and some times it is not
possible to gather those all details. If some persons changes
his/her contact number then changes old one is not possible in
the book.

It is time Consuming process.


There is a chance to loss of data.
Performance of the system is low.
Modification is not possible.
Searching for number is most difficult
Deleting contact is also not possible

Proposed System
In order to eliminate the drawbacks of the existing system, a
system has been developed due to which the person need not
spend much time in identify a phone number and instead
database is built that takes care of every transaction thereby
reducing the burden on customer.

33
By using this proposed system we can reduce the problems of
existing system
In this proposed system we can modify the customers name
and his/her contact number details, searching, viewing and
deleting contacts is also possible.
Searching for contact number is takes less time.

34
DESIGN AND DEVELOPMENT
OF TELEPHONE DIRECTORY
SYSTEM

35
SYSTEM DESIGN:

Hardware Requirements:

Processor : Intel P-IV based system

RAM : 64MB to 512MB

Hard Disk : 20GB to 80GB

Key Board : 101 Standard

Mouse : Optical

Monitor : Samsung 17’’

Software Requirements:

Language : J2SDK 1.4.0

Operating System : Windows NT/98/2000/XP


36
Package : Ms Office 2003

Using visual paradism software for drawing UML diagrams

OUTPUT

37
39
40
41
42
CONCLUSION

43
CONCLUSION;-

The aim of this project was to build an Telephone directory


through which allowed to add,search, delete contacts of
individual andaccess toexternal memorydevice. At the
completion of this project we are able to add, search and
delete contacts hence the project is completed successfully. A
approximate model of Telephone Directory was assembled
using keypad, lcd, microcontroller and EEPROM.

44
BIBLIOGRAPHY

45
BIBLIOGRAPHY

1.https://code-projects.org/telephone- directory-in-c++-with-
sourcecode/

2.https://www.scribd.com/doc/134832923/source-code-for-
telephone-system-in-c++

3.https://en.wikipedia.org/wiki/telephone-information-on-
system

4.NCERT COMPUTER SCIENCE XI TEXTBOOK

5.NCERT COMPURT SCIENCE XII TEXTBOOK

46
SOURCE CODE

47
SOURE CODE

// TELEPHONE DIRECTORY SYSTEM

#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;

48
void get(void);

void show(void);

void modify(void);
};

void stud::get(void)

int i=0;

cout<<"\n Enter name -> ";

cin.get(name[i]);

while(name[i]!='\n')
{
i=i+1

cin.get(name[i]);

}
cin.getline(name,20,'\n');

cout<<" Enter address-> ";

cin.getline(address,20,'\n');

fflush(stdin);

cout<<" Enter ph_no\t-> \t";


49
cin>>ph_no;

fflush(stdin);

void stud::show(void)

cout<<"\n";

cout<<" NAME :"<<"\t"<<name<<"\n";

cout<<" ADDRESS :"<<"\t"<<address<<"\n";

cout<<" Ph_No :"<<"\t"<<ph_no<<"\n";


}

void main()

int gdriver = DETECT, gmode, errorcode;

int x,y;

int midx,midy;

/* initialize graphics and local variables */

initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");


/* read result of initialization */
50
errorcode = graphresult();

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


{
printf("Graphics error: %s\n", 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" );
51
setcolor(WHITE);

outtextxy(250,200,"TO");

settextstyle(8,0,5);

setfillstyle(1,DARKGRAY);

setcolor(WHITE);

outtextxy(60,350,"\n\nTELEPHONE 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<<"\n\t\t\tIncorrect password";

cout<<"\n\t\t\tTry again";
52
getchar();

goto g;

}
else
{

stud s;

char name[20];

char name1[20];

int ch;

clrscr();

setbkcolor(BLUE);

setcolor(YELLOW);

closegraph();

z:

cout<<"\n\n\n\n\n\n\n\n\n";

initgraph(&gdriver, &gmode,"c:\\turboc3\\bgi");

setcolor(BLUE);

rectangle(60,10,600,400);
53
setfillstyle(1,YELLOW);

bar(61,11,599,399);

outtextxy(200,30," HELP -> PRESS ANY KEY 1 TO 6 " );

settextstyle(TRIPLEX_FONT ,HORIZ_DIR,4);

outtextxy(220,50,"\n\n1. TO ADD " );

setcolor(BLUE);

settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);

outtextxy(220,100,"\n\n2. TO SHOW " );

setcolor(BLUE);

settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);

outtextxy(220,150,"\n\n3. TO SEARCH " );

setcolor(BLUE);

settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);

outtextxy(220,200,"4.\n\n TO MODIFY " );


setcolor(BLUE);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
outtextxy(220,250,"\n\n\n5. TO DELETE " );
setcolor(BLUE);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
outtextxy(220,300,"\n\n\n6. TO EXIT " );
54
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<<"\n\n";
fstream f;
55
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();
56
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<<"\n\n\n Enter name whose record to be search :";
cin>>name;
do
{
f.read((char *)&s,sizeof(s));
if(f.eof()==1) {break;}
if(strcmpi(s.name,name)==0)
{
cout<<"\n Name :"<<s.name;
cout<<"\n address :"<<s.address;
cout<<"\n phone_no :"<<s.ph_no;
getchar();
}
}while(f);
f.close();
settextstyle(7,0,1);
outtextxy(250,410,"Do You Want To Continue:");
ans=getchar();
if(ans=='Y'||ans=='y')
goto z;
else
{ 57
closegraph();
break;
}

case 4: //for the modification


{
clrscr();
char ans;
fstream f; stud s;
char name[20]; char address[20]; unsigned int ph_no;
f.open("rec",ios::in|ios::binary);
cout<<"\n\n\n Enter person ph_no whose record to
be changed :";
cin>>ph_no;
do
{
f.read((char *)&s,sizeof(s));
if(f.eof()==1) {break;}

if(s.ph_no==ph_no)
{
cout<<"\n Current Name :"<<s.name;
cout<<"\n Current Address
:"<<s.address;
cout<<"\n Current Phone No :"<<s.ph_no;
getchar();
cout<<"\n Enter the new name :";
cin>>name;
cout<<"\n Enter the city :";
cin>>address;
cout<<"\n Enter new ph_no :";
cin>>ph_no;
strcpy(s.name,name);
58
strcpy(s.address,address);
s.ph_no=ph_no;
int l=f.tellg();
f.close();
f.open("rec",ios::out|ios::binary|ios::ate);
f.seekg(l-sizeof(s));
f.write((char *)&s,sizeof(s));
}
}while(f);
f.close();
outtextxy(290,360, " Do you want to continue :-");
ans=getche();
if(ans=='Y'||ans=='y')
{goto z;}
break;
}

case 5: //responsible for the deletion of the record


{
clrscr();
char name[20];
stud s;
ifstream fin;
fstream fout;
fin.open("rec",ios::in|ios::binary);
fout.open("va",ios::app|ios::binary);
cout<<"\n \t\t\t DELETING :-";
int i;
fflush(stdin);
cout<<"\n\n Enter the name :- ";
cin.get(name[i]);
while(name[i]!='\n')
{ 59
i=i+1;
cin.get(name[i]);

fflush(stdin);
fflush(stdout);
cin.getline(name,20,'\n');
while(fin)
{
fin.read((char *)&s,sizeof (s));
if(strcmp(s.name,name)==0)
{fout.read((char *)&s,sizeof(s));

}
else
{if(fin.eof()==1) {break;}fout.write((char *)&s,si }
}
fin.close();
fout.close();
system("del rec");
system("ren va rec");
cout<<"\n Enter is get Deleted:-";
getchar();

char ans;
outtextxy(240,340, " Do you want to continue:- ");
ans=getche();
if (ans=='y' || ans=='Y')
{goto z;}
else
if (ans=='n' || ans=='N')
60
{getchar();
exit(1);
} }
case 6:
{
clearviewport();
outtextxy(250,360,"THE END OF THE PROJECT:-");
outtextxy(260,390,"\n \n\n\n\n PLEASE PRESS ENTER");
getchar();
closegraph();
exit(1);

}
default:
goto z;

}
}

61

You might also like