Linux

Only available on StudyMode
  • Topic: Unicode, Java
  • Pages : 12 (1166 words )
  • Download(s) : 58
  • Published : March 4, 2013
Open Document
Text Preview
TERM PAPER
Of
FOUNDATION OF COMPUTING
Topic: - TELEPHONE DIRECTORY

Submitted To: - Submitted By:- MOHIT JAIN MR.VIJAY KUMAR

SOURCE CODE
//TETEPHONR DIRECTORY.

#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;
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 :");
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];
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;
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;
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)
{
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)
{
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;
(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])
{
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...
tracking img