DSU MICRO PROJECT Final
DSU MICRO PROJECT Final
DSU MICRO PROJECT Final
PVPIT
2.0 Aim of the Micro-Project:
2
5.0 Proposed methodology:
1. Save numbers.
3
MICRO PROJECT REPORT
ON
DATA STRUCTURE USING ‘C’
Title of Micro-Project: Telephone Directory
Adding new records, listing them, modifying them and updating, search
for contacts saved, and deleting the phonebook records are the basic
functions which make up the main menu of this Phonebook application (as
shown in the main menu screenshot below).
This program “my phonebook” facility the user with different records
can add and search easily by using button tools & search options. There are
some features also like: - viewing data in data grid, and logout. Our project
has following: login form “add” button for adding data in database.
“delete” button for deleting data in database. “update” button for updating
data in database. “search” button for searching data in database.
4
2.0Aim of Micro Project:
• This application stores all the details like name, telephone number,
address,sex, and email id in a database.
• This system was developed to reduce the errors that creep up in manual
systems.
• This software also allows to edit, update and search various contact
details.
5
4.0Actual Procedure Followed:
6
6.0 Outputs of the Micro-projects:
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
struct person
{
char name[35];
char address[50];
char father_name[35];
char mother_name[30];
int mbleno;
char sex[50];
char mail[100];
char citision_no[10];
};
void menu ();
void got ();
void start ();
void back();
void addrecord();
void listrecord();
void modifyrecord();
void deleterecord();
7
void searchrecord();
int main()
{
system("color 5f");
start();
return 0;
}
void back()
{
start();
}
void start()
{
menu();
}
void menu()
{
system("cls");
printf("\t\t**********WELCOME TO PHONEBOOK*************");
printf("\n\n\t\t\t MENU\t\t\n\n");
printf("\t1.Add New \t2.List \t3.Exit \n\t4.Modify
\t5.Search\t6.Delete");
switch(getch())
{
case '1':addrecord();
break;
8
case '2': listrecord();
break;
case '3': exit(0);
break;
case '4': modifyrecord();
break;
case '5': searchrecord();
break;
case '6': deleterecord();
break;
default:
system("cls");
printf("\nEnter 1 to 6 only");
printf("\n Enter any key");
getch();
menu();
}
}
void addrecord()
{
system("cls");
FILE *f;
struct person p;
f=fopen("project","ab+");
printf("\n Enter name: ");
got(p.name);
9
printf("\nEnter the address: ");
got(p.address);
printf("\nEnter father name: ");
got(p.father_name);
printf("\nEnter mother name: ");
got(p.mother_name);
printf("\nEnter phone no.:");
scanf("%d",&p.mbleno);
printf("Enter sex:");
got(p.sex);
printf("\nEnter e-mail:");
got(p.mail);
printf("\nEnter citizen no:");
got(p.citision_no);
fwrite(&p,sizeof(p),1,f);
fflush(stdin);
printf("\nrecord saved");
fclose(f);
getch();
system("cls");
menu();
}
10
void listrecord()
{
struct person p;
FILE *f;
f=fopen("project","rb");
if(f==NULL)
{
printf("\nfile opening error in listing :");
exit(1);
}
while(fread(&p,sizeof(p),1,f)==1)
{
printf("\n\n\n YOUR RECORD IS\n\n ");
printf("\nName=%s\nAdress=%s\nFather name=%s\nMother
name=%s\nMobile no=%d\nSex=%s\nE-mail=%s\nCitizen
no=%s",p.name,p.address,p.father_name,p.mother_name,p.mbleno,p.sex,
p.mail,p.citision_no);
getch();
system("cls");
}
fclose(f);
printf("\n Enter any key");
getch();
system("cls");
menu();
}
11
void searchrecord()
{
struct person p;
FILE *f;
char name[100];
f=fopen("project","rb");
if(f==NULL)
{
printf("\n error in opening\a\a\a\a");
exit(1);
}
printf("\nEnter name of person to search\n");
got(name);
while(fread(&p,sizeof(p),1,f)==1)
{
if(strcmp(p.name,name)==0)
{
printf("\n\tDetail Information About %s",name);
printf("\nName:%s\naddress:%s\nFather name:%s\nMother
name:%s\nMobile no:%d\nsex:%s\nE-mail:%s\nCitision
no:%s",p.name,p.address,p.father_name,p.mother_name,p.mbleno,p.sex,p
.mail,p.citision_no);
}
else
printf("file not found");
12
}
fclose(f);
printf("\n Enter any key");
getch();
system("cls");
menu();
}
void deleterecord()
{
struct person p;
FILE *f,*ft;
int flag;
char name[100];
f=fopen("project","rb");
if(f==NULL)
{
}
else
{
ft=fopen("temp","wb+");
if(ft==NULL)
13
else
fflush(stdin);
while(fread(&p,sizeof(p),1,f)==1)
{
if(strcmp(p.name,name)!=0)
fwrite(&p,sizeof(p),1,ft);
if(strcmp(p.name,name)==0)
flag=1;
}
fclose(f);
fclose(ft);
if(flag!=1)
{
printf("NO CONACT'S RECORD TO DELETE.");
remove("temp.txt");
}
else
{
remove("project");
rename("temp.txt","project");
printf("RECORD DELETED SUCCESSFULLY.");
14
}
}
}
printf("\n Enter any key");
getch();
system("cls");
menu();
}
void modifyrecord()
{
int c;
FILE *f;
int flag=0;
struct person p,s;
char name[50];
f=fopen("project","rb+");
if(f==NULL)
{
}
else
15
{
system("cls");
printf("\nEnter CONTACT'S NAME TO MODIFY:\n");
got(name);
while(fread(&p,sizeof(p),1,f)==1)
{
if(strcmp(name,p.name)==0)
{
}
fflush(stdin);
}
if(flag==1)
{
printf("\n your data id modified");
}
else
{
printf(" \n data is not found");
}
fclose(f);
}
printf("\n Enter any key");
getch();
system("cls");
menu();
}
void got(char *name)
{
17
int i=0,j;
char c,ch;
do
{
c=getch();
if(c!=8&&c!=13)
{
*(name+i)=c;
putch(c);
i++;
}
if(c==8)
{
if(i>0)
{
i--;
}
// printf("h");
system("cls");
for(j=0;j<i;j++)
{
ch=*(name+j);
putch(ch);
18
}
}while(c!=13);
*(name+i)='\0';
}
OUTPUT:
1) Display:
19
2) Add New:
3) List:
20
4) Modify:
5) Search:
21
6) Delete:
7) Exit:
22
7.0 Skill Developed/ learning out of this Micro-Project:
➢ Time Management.
➢ Stress Management.
➢ Study Skills.
➢ Money Management.
➢ Assertiveness Skills.
➢ Well-Developed Self Care Skills.
➢ Keeping Safe and Avoiding Risky Behaviors.
➢ Seeking Assistance When Needed.
23