Address Book in c

33
TERM PAPER TOPIC:-ADDRESS BOOK Submitted TO:- Submitted by:- Mr Manjinder Singh ajay kumar Roll No:-Rd1206 Section:-271 Regd. No:-10804014 1

description

rock

Transcript of Address Book in c

Page 1: Address Book in c

TERM PAPER

TOPIC:-ADDRESS BOOK

Submitted TO:- Submitted by:-

Mr Manjinder Singh ajay kumar

Roll No:-Rd1206

Section:-271

Regd. No:-10804014

1

Page 2: Address Book in c

ACKNOWLEDGEMENT

As the professional courses do not only required the theoretical

knowledge but need to cover practical aspect too. Universities have

started conducting training programs for students. So, that they get

simple view of practical knowledge.

No work of significance can be claimed on a result of an individual

Efforts and same holds true further for this project as well, for through it

carries my name the energy of many have contributed in no small

measure in completion of this project.

I am very thankful to my friend and our teachers “Mr. Manjinder Singh” who help me to make this project.

KAMAL

2

Page 3: Address Book in c

Table of contents

1. Introduction2. Proposed system

i. Descriptionii. System requirements

3. Requirement Analysis4. System Design5. Source code6. Testing7. Future scope of project

3

Page 4: Address Book in c

INTRODUCTION

As the name specifies "Address book" is a software developed for managing various details of persons. Through this address book we can handle the details of persons properly which can not be possible to keep in mobile as there are less space in detail section.This particular project deals with the problems on managing the details of person and avoids the problems of losing the details.

Identification of the drawbacks of the existing system leads to the designing of computerized system that will be compatible to the existing system with the system which is more user friendly and more GUI oriented. We can improve the efficiency of the system, thus overcome the drawbacks of the existing system.· Less human error· Strength and strain of manual labor can be reduced · High security· Data consistency· Easy to handle· Easy data updating · Easy record keeping· Backup data can be easily genera

4

Page 5: Address Book in c

PROPOSED SYSTEM

The following documentation is a project the “Name of the term paper allotted”. It is a detailed summary of all the drawbacks of the old system and how the new proposed system overcomes these shortcomings. The new system takes into account the various factors while designing a new system. It keeps into the account the Economical bandwidth available for the new system. The foremost thing that is taken care of is the Need and Requirements of the User.

DESCRIPTION

Before developing software we keep following things in mind that we can develop powerful and quality software

PROBLEM STATEMENT

o Problem statement was to design a module:o Which is user friendlyo Which will restrict the user from accessing other user’s data.o Which will help user in viewing his data and privileges.o Which will help the administrator to handle all the changes.

FUNCTIONS TO BE PROVIDED:

The system will be user friendly and completely menu driven so that the users shall have no problem in using all options.

o The system will be efficient and fast in response.o The system will be customized according to needs.o It would help in reducing the complexity.

o Computerized Address Book system helps in managing things accurately

o It is also a time saving process.

o Helps in saving a large amount of data without the fear of saving it.

o Without the interference of any human, one can easily login and get through the Address

Book.

5

Page 6: Address Book in c

SYSTEM REQUIREMENTS

Operating System: Windows 2000/NT/Xp/Vista

RAM: 256 MB or more

HARD DISK 40 GB or more

Processor P3 or High

Compiler Standard C++ Compiler

6

Page 7: Address Book in c

Requirement Analysis:

THE PROJECT WHICH IS GIVEN TO ME I CAN BE MADE ON ANY WINDOWS LIKE WINDOWS-VISTA WINDOWSXP, WINDOWS 2000. THE MAIN CONDITION IS THAT IT SHOULD HAVE MICROSOFT INSTALLED WITH MICROSOFT WINDOWS AS BASIC NECCESSSITY. THE SYSTEM SHOLD HAVE RAM OF 256MB OR MORE. HARD DISK CAPACITY OF 40GB OR MORE. PROCESSOR MUST BE PENTIUM 3 0R 4 WITH C++ COMPILER.

7

Page 8: Address Book in c

System Design

8

MINI PROJECT-SIMPLE ADDRESS BOOK

Enter your choice?

1 - 9

New

Entry

Do you want to continue?

START

STOP

Display an

Entry

Delete an

Entry

Display an entry

Empty a book

Save

Entry

Load

Entries

Delete all Saved

Files

End

Page 9: Address Book in c

SOURCE CODE

#include<stdio.h>

#include<stdlib.h>

#include<conio.h>

#include<alloc.h>

#include<string.h>

#include<graphics.h>

struct entry

{

char name[50];

char nick[50];

char email[50];

char address[50];

char city[50];

char cont[50];

char pin[50];

struct entry *lptr;

struct entry *rptr;

}*temp,*newe,*l,*r;

9

Page 10: Address Book in c

typedef struct entry *list;

void newentry();

void display(char n[50]);

void deletentry(char n[50]);

void displayall();

void makempty();

int isempty();

void saventry();

void loadentry();

void deleteall();

void newentry()

{

char a[50],b[50],f[50],g[50],c[50],d[50],e[50];

int i,k=0;

printf("Enter the Datas for the New Entry:");

printf("Name :");

scanf("%s",a);

printf("Nick name :");

scanf("%s",b);

printf("E-mail ID :");

scanf("%s",c);

printf("Address :");

10

Page 11: Address Book in c

scanf("%s",d);

printf("City :");

scanf("%s",e);

printf("Contact No:");

scanf("%s",f);

printf("Pincode :");

scanf("%s",g);

newe=(struct entry*)malloc(sizeof(struct entry));

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

{

newe->name[i]=' ';

newe->nick[i]=' ';

newe->email[i]=' ';

newe->address[i]=' ';

newe->city[i]=' ';

newe->cont[i]=' ';

newe->pin[i]=' ';

}

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

{

newe->name[i]=a[i];

newe->nick[i]=b[i];

11

Page 12: Address Book in c

newe->email[i]=c[i];

newe->address[i]=d[i];

newe->city[i]=e[i];

newe->cont[i]=f[i];

newe->pin[i]=g[i];

}

if(isempty())

{

newe->lptr=newe->rptr=NULL;

l=r=newe;

printf("Your Entry is Added");

}

else

{

temp=l;

while(temp!=NULL)

{

i=stricmp(newe->name,temp->name);

if(i<0)

break;

else if(i>0)

temp=temp->rptr;

12

Page 13: Address Book in c

else if(i==0)

{

printf("Name Already Exists.Entry cannot be Added");

k=1;

break;

}

}

if(k!=1)

{

if(temp==l)

{

newe->lptr=NULL;

newe->rptr=l;

l->lptr=newe;

l=newe;

printf("Your Entry is Added");

}

else if(temp==NULL)

{

newe->rptr=NULL;

newe->lptr=r;

r->rptr=newe;

13

Page 14: Address Book in c

r=newe;

printf("Your Entry is Added");

}

else

{

newe->rptr=temp;

newe->lptr=temp->lptr;

temp->lptr=newe;

(newe->lptr)->rptr=newe;

printf("Your Entry is Added");

}

}

}

}

void displayall()

{ int n=1;

if(!isempty())

{

temp=l;

while(temp!=NULL)

{

14

Page 15: Address Book in c

printf("[%d] Name :%s Nick Name :%s E-mail ID :%s address :%s City :%s Contact.No:%s Pin code :%s",n,temp->name,temp->nick,temp->email,temp->address,temp->city,temp->cont,temp->pin);

temp=temp->rptr;

n++;

}

}

else

printf("Address Book is Empty");

}

void deletentry(char n[50])

{

int i;

if(isempty())

printf("Address Book is Empty");

else{

temp=l;

while(temp!=NULL)

{

i=stricmp(temp->name,n);

if(i==NULL)

{

15

Page 16: Address Book in c

if(l==r)

{

l=r=NULL;

printf("Entry deleted");

break;

}

else if(temp==l)

{

l=l->rptr;

l->lptr=NULL;

printf("Entry deleted");

break;

}

else if(temp==r)

{

r=r->lptr;

r->rptr=NULL;

printf("Entry deleted");

break;

}

else{

(temp->lptr)->rptr=temp->rptr;

16

Page 17: Address Book in c

(temp->rptr)->lptr=temp->lptr;

printf("Entry deleted");

break;

}

}

temp=temp->rptr;

}

if(temp==NULL)

printf("Not Found");

}

}

int isempty()

{

return l==NULL;

}

void makempty()

{

l=r=NULL;

printf("Address Book is Emptied");

}

void display(char n[50])

17

Page 18: Address Book in c

{

int i,p=1;

if(isempty())

printf("Address Book is Empty");

else

{

temp=l;

while(temp!=NULL)

{

i=stricmp(temp->name,n);

if(i==NULL)

{if(p==1)

printf("Entry is found in %dst position",p);

else if(p==2)

printf("Entry is found in %dnd position",p);

else if (p==3)

printf("Entry is found in %drd position",p);

else

printf("Entry is found in %dth position",p);

printf("Name :%s Nick Name :%s E-mail ID :%s address :%s City :%s Contact.No:%s Pin code :%s ",temp->name,temp->nick,temp->email,temp->address,temp->city,temp->cont,temp->pin);

break;

18

Page 19: Address Book in c

}

temp=temp->rptr;

p++;

}

if(temp==NULL)

printf("Entry Not Found");

}

}

void main()

{

int l=1,m;

int gd=DETECT,gm;

char n[50];

initgraph(&gd,&gm,"c:\tc\bgi");

while(l!=8)

{

clrscr();

textmode(C80);

textcolor(4);

cprintf("********************************************************************************#------------------------MINI PROJECT-SIMPLE ADDRESS BOOK----------------------

19

Page 20: Address Book in c

#********************************************************************************");

cprintf("Enter Your Choice");

printf(" ");

cprintf("(1)-New Entry");

printf(" ");

cprintf("(2)-Display an Entry");

printf(" ");

cprintf("(3)-Delete an Entry");

printf(" ");

cprintf("(4)-Display all Entries");

printf(" ");

cprintf("(5)-Empty the book");

printf(" ");

cprintf("(6)-Save Entry");

printf(" ");

cprintf("(7)-Load Entries");

printf(" ");

cprintf("(8)-Delete All Saved Files");

printf(" ");

cprintf("(9)-End");

printf(" ");

20

Page 21: Address Book in c

cprintf("********************************************************************************");

printf(" ");

scanf("%d",&l);

switch(l)

{

case 1:

textcolor(2);

newentry();

getch();

break;

case 2:

textcolor(2);

cprintf("Enter the Name of the Person to Display");

printf(" ");

scanf("%s",&n);

display(n);

getch();

break;

case 3:

textcolor(2);

cprintf("Enter the Name of the Person to Delete");

printf(" ");21

Page 22: Address Book in c

scanf("%s",&n);

deletentry(n);

getch();

break;

case 4:

textcolor(2);

displayall();

getch();

break;

case 5:

textcolor(2);

makempty();

getch();

break;

case 6:

textcolor(2);

saventry();

getch();

break;

case 7:

textcolor(2);

loadentry();

22

Page 23: Address Book in c

getch();

break;

case 8:

textcolor(2);

deleteall();

getch();

break;

case 9:

textcolor(2);

printf("Program Ends Here.Thank You!!!");

printf(" ");

getch();

break;

default:

textcolor(2);

printf("Enter a Valid Choice from 1-9 only");

printf(" ");

getch();

break;

}

}

getch();

23

Page 24: Address Book in c

}

void saventry()

{

char n[50];

int c;

printf("Enter the Name of the Person");

scanf("%s",n);

list t;

if(isempty())

printf("Address Book is Empty");

else

{

FILE *f;

f=fopen("entry.c","a");

int i;t=l;

while(t!=NULL)

{

i=stricmp(t->name,n);

if(i==0)

{

fprintf(f,"%s %s %s %s %s %s %s",t->name,t->nick,t->email,t->address,t->city,t->cont,t->pin);

printf("Your Entry Saved");24

Page 25: Address Book in c

printf("Add Another Entry? (1-yes/2-no)");

scanf("%d",&c);

if(c==1)

saventry();

else if(c==2)

break;

}

t=t->rptr;

}

fclose(f);

if(t==NULL)

printf("Entry Not Found");

}

}

void loadentry()

{

int i=1;

list t;

FILE *f;

f=fopen("entry.c","r");

25

Page 26: Address Book in c

if(f==NULL)

{

printf("Cannot Open");

exit(1);

}

while(fscanf(f," %s %s %s %s %s %s %s",t->name,t->nick,t->email,t->address,t->city,t->cont,t->pin)!=EOF)

{ printf("[%d] Name :%s Nick Name :%s E-mail ID :%s address :%s City :%s Contact.No:%s Pin code :%s",i,t->name,t->nick,t->email,t->address,t->city,t->cont,t->pin);

i++;}

fclose(f);

}

void deleteall()

{

FILE *f;

f=fopen("entry.c","w");

fclose(f);

printf("all saved files were delete");

}

TESTING

26

Page 27: Address Book in c

THE SOURCECODE DECLARED ABOVE FOR THE PROGRAM OF ADDRESS BOOK HAS BEEN TESTED AND IT HAS BEEN FOUND THAT THE ABOVE SOURCE CODE IS OKAY AND CORRECT.THE PROGRAM INVOLVES MANY TYPE OF CONVERSIONS. THESE CONVERSIONS HAS TO DONE CAREFULLY.

MAINLY THERE ARE TWO TYPES OF TESTING:

1-SYSTEM TESTING AND

2-INTEGRATION TESTING

SYSTEM TESTING INVOLVES WHOLE TESTING OF PROGRAM AT ONCE AND INTEGRATION TESTING INVOLVES THE BREAKING OF PROGRAM INTO MODULES & THEN TEST.

OUTPUT:-

********************************************************************************#------------------------MINI PROJECT-SIMPLE ADDRESS BOOK----------------------#********************************************************************************Enter Your Choice (1)-New Entry (2)-Display an Entry (3)-Delete an Entry (4)-Display all Entries (5)-Empty the book (6)-Save Entry (7)-Load Entries (8)-Delete All Saved Files (9)-End ******************************************************************************** 1Enter the Datas for the New Entry:Name :AnkurNick name :AkkiE-mail ID :[email protected] :JanakPuriCity :DelhiContact No:123456789Pincode :110028Your Entry is Added

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

27

Page 28: Address Book in c

of the person of which the address is entered.We can also add or subtract details of the individual.

28