Sie sind auf Seite 1von 28

Contact Management System

Chapter 1

Introduction
We have discussed so far various features of C language and are ready to write and
execute program of modest complexity. However, before attempting to develop
complex programs, it is worthwhile to consider some programming techniques that
would help design efficient and error free.

The program development process includes three important stages, namely, program
design, program coding and program testing. All the three stages contribute to the
production of high quality program.

In “CONTACT MANAGEMENT SYSTEM” we have done system design, source


coding, and program testing and added many more features to facilitate the user with
the best. We have given the user the facility to enter the person’s record and providing
the option to save and delete that record and many more options.

We can improve the efficiency of the system, thus overcome the drawbacks of the
existing system.
· Less human error
· Strength and strain of manual labour can be reduced
· High security
· Data consistency
· Easy to handle
· Easy data updating
· Easy record keeping
· Backup data can be easily general

Dept. of CSE, NHCE Page 1


Contact Management System

Chapter 2

Materials and Methods


The Title of the Program is to develop a program which deals with the combination of
structures, arrays, File pointers and other functions. This program could do some
operations on arrays such as insertion, deletion, sorting, searching, update, retrieve,
merging, append,exit.

By implementing this program we can execute the inserted contact data,


deletion of the data, searching, updating, append, exit with numbers by using arrays
and file pointers. This program is implemented for only numbers that can enter into an
array. To do this analysis manually it takes a lot of time and patience but by
implementing this program using a high level language like C it becomes much easier.
But before going to make final solution for the problem, the problem must be
analysed.

First of all the basic information regarding the program which consists of complex
numbers. This program is solved by using several methods like one can solve this
program using user defined functions concept, loops conditions, go to statements. In
this abstract we used the concept of functions, while loop, for loop, switch case and if
condition’s which helps to execute the problem much easier .The following steps are
followed while implementing the given program using if and while loop.

 The input is entered i.e., the value of choice (the menu no) select the particular
menu.
 Next it goes to particular menu and then goto the particular function.
 It prints the resultant value which came from the execution.

The outcome of the work is one can get the required changes like inserting or
deleting or sorting or merging or append or retrieve or update or exit for a given
array.

Dept. of CSE, NHCE Page 2


Contact Management System

Structures

We have seen that arrays can be used to represent a group of data items that
belongs to same data type. If we want to represent a collection of data items of
different data types using a single name, then we cannot use an array. C supports a
constructed data type known as Structure, which is a method for packing data of
different data types. A structure is a convenient tool for handling a group of logically
related data items. Structures help to organize complex data in a more meaningful
way. It is a powerful concept that we may often need to Use in our program design.

Definition:

A group of data items that belongs to different data types is known as Structure.

‘Struct’ : It is a keyword and is used to declare a Structure.

Declaration of structure:

structstruct_name
{
Data item-1;
Data item-2;
…………
…………
Data item-n;
};

Declaration of structure variable:

structstruct_name identifier;

(or)

structstruct_name dentifier-1,identifier-2,.......,identifier-n;

(Access operator):

It is used to access the data items of a structure with the help of structure variable.

Dept. of CSE, NHCE Page 3


Contact Management System

Syntax:
struct_variable . Data item;

AIM:

• To develop a “Phonebook contact” application using c programming.

• This program is very useful now-a-days to store complete information under


single contact number.

• This program also has options to deletion and modification of the entered
contact number.

Advantages:

• It becomes easy for the user to store complete information (e-mail id, address,
e.t.c) about his contact.

• It is easy for the user to just search his required contact number by just typing
name of the contact.

Disadvantages:

• Sometimes it becomes difficult to store more contacts (over 150).

Future Enhancements:-

 It becomes even difficult to store contacts with two or more contact numbers

SOFTWARE REQUIREMENTS:

• This application is developed in Microsoft windows xp or later operating


system.
• This Phonebook application is coded and made using the following compilers:
1. Code::blocks.
2. Turbo c.

Dept. of CSE, NHCE Page 4


Contact Management System

HARDWARE REQUIREMENTS:

• This Application size is 33Kb and the size of the code is 5Kb so such amount of
memory is required from hard disk.
• RAM: minimum 256MB.
• Mouse, keyboard.

Dept. of CSE, NHCE Page 5


Contact Management System

Chapter 3
Result and Discussion

ALGORITHM:

1. Start.
2. Display the options on the screen.
3. Read name, address, father name, mother name, mobile number, gender.
4. Print “WELCOME TO CONTACT MANAGEMENT SYSTEM” and
“Menu” on the screen
a. Add contact
b. Print all contacts
c. Modify contacts
d. Search contact
e. Delete contact
f. Close phone book
5. Now for Addrecord(),arranging data as Enter name ,Enter address ,Enter
phone no, Email ID and finally operations record saved ,Enter any key.
6. Now for listrecord(),arranging data as
a. if data is empty print file opening error in listing
b. Elseprint your record: name,address,mobile no, Email ID
c. After all these print enter any key
7. Now for searchrecord(),arranging data as
a. if data is insufficient print error in opening
b. Else
c. print enter name of contact to be searched and
i. If (strcmp(p.name,name)==0)
ii. print detail information about name and
name,address,mobilenum, Email.
d. After entering all these, print enter any key
8. Now for deleterecord(),arranging the data as
a. If (f==null)
b. print contact’s data not added yet
i. else
ii. if(f==null)

Dept. of CSE, NHCE Page 6


Contact Management System

iii. print file opening error


iv. Else
v. Print enter contact’s details.
9. if (flag!=1)
a. print no contact’s record to delete
b. Else
c. print record deleted successfully
d. After entering all the data print enter any key
10.for modifyrecord(),arranging the data as
a. If (f==null)
b. print contact’s data not added yet
c. Else
d. enter contact’s name to modify
i. Print enter name , enter address ,mobile number, Email after
entering the data
ii. print your data is modified
iii. Else
iv. print data is not found
v. Finally print enter any key.
11.Redisplay the menu for user required input.

Dept. of CSE, NHCE Page 7


Contact Management System

CODE & IMPLEMENTATION


#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
#include<stdlib.h>
#include<dos.h>
struct contact
{
longph;
char name[20],add[20],email[30];
} list;
char query[20],name[20];
FILE *fp, *ft;
inti,n,ch,l,found;

int main()
{
main:
system("cls"); /* ************Main menu
*********************** */
printf("\n\t **** Welcome to Contact Management System ****");
printf("\n\n\n\t\t\tMAIN MENU\n\t\t=====================\n\t\t[1]
Add a new Contact\n\t\t[2] List all Contacts\n\t\t[3] Search for
contact\n\t\t[4] Edit a Contact\n\t\t[5] Delete a Contact\n\t\t[0]
Exit\n\t\t=================\n\t\t");
printf("Enter the choice:");
scanf("%d",&ch);
switch(ch)
{

case 0:

printf("\n\n\t\tAre you sure you want to exit?");

break;

Dept. of CSE, NHCE Page 8


Contact Management System

/* *********************Add new contacts************ */

case 1:

system("cls");

fp=fopen("contact.dll","a");

for (;;)

{
fflush(stdin);

printf("To exit enter blank space in the name input\nName (Use


identical):");

scanf("%[^\n]",&list.name);

if(stricmp(list.name,"")==0 || stricmp(list.name," ")==0)

break;

fflush(stdin);

printf("Phone:");

scanf("%ld",&list.ph);

fflush(stdin);

printf("address:");

scanf("%[^\n]",&list.add);

fflush(stdin);

Dept. of CSE, NHCE Page 9


Contact Management System

printf("email address:");

gets(list.email);

printf("\n");

fwrite(&list,sizeof(list),1,fp);

fclose(fp);

break;

/* ****************list of contacts***********************/

case 2:

system("cls");

printf("\n\t\t================================\n\t\t\tLIST OF
CONTACTS\n\t\t================================\n\nName\
t\tPhone No\t Address\t\tE-mail
ad.\n=================================================
================\n\n");

for(i=97; i<=122; i=i+1)

fp=fopen("contact.dll","r");

fflush(stdin);

found=0;

Dept. of CSE, NHCE Page 10


Contact Management System

while(fread(&list,sizeof(list),1,fp)==1)

if(list.name[0]==i || list.name[0]==i-32)

printf("\nName\t: %s\nPhone\t: %ld\nAddress\t: %s\nEmail\t:


%s\n",list.name,

list.ph,list.add,list.email);

found++;

if(found!=0)

{
printf("===============================================
============ [%c]-(%d)\n\n",i-32,found);

getch();
}

fclose(fp);

break;

Dept. of CSE, NHCE Page 11


Contact Management System

/* *******************search contacts**********************
*/

case 3:

system("cls");

do

found=0;

printf("\n\n\t..::CONTACT
SEARCH\n\t===========================\n\t..::Name of contact
to search: ");

fflush(stdin);

scanf("%[^\n]",&query);

l=strlen(query);

fp=fopen("contact.dll","r");

system("cls");

printf("\n\n..::Search result for '%s'


\n===================================================
\n",query);

while(fread(&list,sizeof(list),1,fp)==1)

for(i=0; i<=l; i++)

Dept. of CSE, NHCE Page 12


Contact Management System

name[i]=list.name[i];

name[l]='\0';

if(stricmp(name,query)==0)

printf("\n..::Name\t: %s\n..::Phone\t: %ld\n..::Address\t: %s\n..::Email\t:


%s\n",list.name,list.ph,list.add,list.email);

found++;

if (found%4==0)

printf("..::Press any key to continue...");

getch();

if(found==0)

printf("\n..::No match found!");

else

printf("\n..::%d match(s) found!",found);

Dept. of CSE, NHCE Page 13


Contact Management System

fclose(fp);

printf("\n ..::Try again?\n\n\t[1] Yes\t\t[0] No\n\t");

scanf("%d",&ch);

}
while(ch==1);

break;

/* *********************editcontacts************************/

case 4:

system("cls");

fp=fopen("contact.dll","r");

ft=fopen("temp.dat","w");

fflush(stdin);

printf("..::Edit
contact\n===============================\n\n\t..::Enter the
name of contact to edit:");

scanf("%[^\n]",name);

while(fread(&list,sizeof(list),1,fp)==1)

if(stricmp(name,list.name)!=0)

fwrite(&list,sizeof(list),1,ft);

Dept. of CSE, NHCE Page 14


Contact Management System

fflush(stdin);

printf("\n\n..::Editing '%s'\n\n",name);

printf("..::Name(Use identical):");

scanf("%[^\n]",&list.name);

fflush(stdin);

printf("..::Phone:");

scanf("%ld",&list.ph);

fflush(stdin);

printf("..::address:");

scanf("%[^\n]",&list.add);

fflush(stdin);

printf("..::email address:");

gets(list.email);

printf("\n");

fwrite(&list,sizeof(list),1,ft);

fclose(fp);

fclose(ft);

Dept. of CSE, NHCE Page 15


Contact Management System

remove("contact.dll");

rename("temp.dat","contact.dll");

break;

/* ********************deletecontacts**********************/

case 5:

system("cls");

fflush(stdin);

printf("\n\n\t..::DELETE A
CONTACT\n\t==========================\n\t..::Enter the name
of contact to delete:");

scanf("%[^\n]",&name);

fp=fopen("contact.dll","r");

ft=fopen("temp.dat","w");

while(fread(&list,sizeof(list),1,fp)!=0)

if (stricmp(name,list.name)!=0)

fwrite(&list,sizeof(list),1,ft);

fclose(fp);

fclose(ft);

remove("contact.dll");

Dept. of CSE, NHCE Page 16


Contact Management System

rename("temp.dat","contact.dll");

break;

default:

printf("Invalid choice");

break;

printf("\n\n\n..::Enter the Choice:\n\n\t[1] Main Menu\t\t[0] Exit\n");

scanf("%d",&ch);

switch (ch)

case 1:

goto main;

case 0:

break;

default:

printf("Invalid choice");

break;

Dept. of CSE, NHCE Page 17


Contact Management System

return 0;

Dept. of CSE, NHCE Page 18


Contact Management System

SCREENSHOTS:

Fig 3.1 Main Menu

Dept. of CSE, NHCE Page 19


Contact Management System

Fig 3.2 Adding of Contacts

Dept. of CSE, NHCE Page 20


Contact Management System

Fig 3.2.1 Adding of contacts

Dept. of CSE, NHCE Page 21


Contact Management System

Fig 3.3 Searching a Contact

Dept. of CSE, NHCE Page 22


Contact Management System

Fig 3.4 Editing a Contact

Dept. of CSE, NHCE Page 23


Contact Management System

Fig3.5 Deleting a contact

Dept. of CSE, NHCE Page 24


Contact Management System

Fig3.6Displaying of contacts after deleting.

Dept. of CSE, NHCE Page 25


Contact Management System

CONCLUSION:

This program makes the user simpler to connect to his contact. The contact personal
information and family information is stored under a single number this would benefit
the user to easily search and locate his required contact. This program deals with four
operations of adding contacts, deleting them, modifying, searching according the
user’s choice. Each operation is made as an individual function and so control enters
to different structures and all the data added or modified or deleted is going to be
stored in a .txt file using FILE pointers.

Dept. of CSE, NHCE Page 26


Contact Management System

FUTURE SCOPE:

In future one change can be done by adding the fingerprints of the persons of which
the address is entered.And one more major change which can be done in this project is
that to add the snaps of the person of which the address is entered.We can also add or
subtract details of the individual.

Dept. of CSE, NHCE Page 27


Contact Management System

REFERENCE:

[1] https://genesisdatabase.wordpress.com/2010/10/11/simple-phonebook-

[2] https://www.codeproject.com/Messages/44740/C-programming-phonebook-

Dept. of CSE, NHCE Page 28

Das könnte Ihnen auch gefallen