HOW TO MAKE A TELEPHONE DIRECTORY IN C LANGUAGE ?
DESCRIPTION :
This is a simple TELEPHONE DIRECTORY in which we can ADD a NEW ENTRY on Runtime . Also DISPLAY , EDIT & DELETE an ENTRY on RUNTIME . And DISPLAY ALL ENTRIES.
DATASTRUCTURE :
LINKED LIST
LIBRARIES :
- #include<stdio.h> : This library is used for Input and Output. i-e Printf and Scanf are the functions of stdio.h
- #include<stdlib.h> : This library is used for malloc and calloc function .
- #include<string.h> : This library is used for comparison (in this project). String library has more other functions but we will only use it for comparison here.
STEP 1 : Make a Structure :
We will use STRUCT because C-Language(Procedural Oriented Language) does not allow Classes. char Array is use to store First Name , Last Name , Address & City because C - Language does not allow dataType string.
STEP 2 : Make a Function NewEntry() :
This function will call when user wants to ADD a new Entry. Malloc will reserve in memory for New Node on RunTime. This Function has a return type struct Person because it will return a Node . At beginning the Linked List is NULL i-e *start = NULL .
STEP 3 : Make a Function SaveNewEntry() :
This Function will Call the above function NewEntry() & take input from the user on RunTime . And after taking all the input it will save it in a new Node either start , End or Mid of the Linked List & generate a message "YOUR ENTRY IS ADDED". If the user is not greater than 18, it will genarate a message that "You are not eligible to register". Means the user (greater than age 18) are eligible to get a connection.
STEP 4 : Make a Function DisplayAll() :
This Function will Display all the Entries present in the whole TELEPHONE DIRECTORY.
Status Pointer is use to visit each node. If the status is not equals to NULL then it will Print or Display all Data present in the Directory.
STEP 5 : Make a Function DeleteAnEntry() :
This Function will Delete a specific Entry by asking the First Name from the User . If there is No Entry then the user will generate a message that there is no entry in Directory. It will use a function strcmp to compare the first name given by the user with the first name present in the LINKED LIST. And also ask the user if he/she is sure or not. If the answer is YES then it will Delete the whole Entry and display a message "Record Deleted" .
STEP 6 : Make a Function DisplayAnEntry() :
This Function will Display an specific Entry. Status Pointer is use to search a node . Here Status will start from the first Node (start) and visit every node until it will find the code entered by the user . When the code entered by the user is similar to the code of status then it will stop searching and return the entry where status stands.
STEP 7 : Make a Function EditAnEntry() :
This Function will Edit the existing Entry after searching the Entry by First Name . If the Linked List is empty and there is no entry to edit then it will generate a message "Empty Directory". If the user name does not match with the user name exist in the Linked List then it will generate a message "No matching records find" .
STEP 8 : Make a Function Choise() :
This Function will ask the user if he/she wants to Add a New Entry or Display an Entry or Edit an Entry or Delete an Entry or Display All Entries or he/she wants to End the Program. The user will add a number 1 to add a new Entry , 2 for Display an Entry , 3 for Edit an Entry , 4 to Delete an Entry , 5 to Display all Entries and 6 to End the Program .
STEP 9 : MAIN( )
We will call the function choise() in main and we will use switch Case to call every above function .
BIG O COMPEXITY :
All the functions have the complexity O(n) because the loop will traverse all the nodes and ends with NULL .
HOW MANY ENTRIES WE CAN ADD IN THIS DIRECTORY ?
We can add entries as much as we want because the directory is created by using the Data Structure Linked List and Linked List have no indexing.
******************************************************************************
If you have any Query regarding this project feel free to ask in the Comment Section.
Thanks 😃
3 Comments
Loved your blog page!!!The stuff that you have remarked up here is superbly wonderful and I vigorously thank you for the same...
ReplyDeleteWeb Development Solution
You create sense out of the foremost complex topics.
ReplyDeleteMen
hello, i copied your coding and a few errors occured which i can't seem to fix it. can you help me
ReplyDelete