Mini Project for Phonebook in C with Source Code
The Mini Project for Phonebook in C is a consoled based application created using c programming language. This system is a simple mini project and compiled in Code::Blocks IDE using GCC compiler. In this project you can add, search, edit and you can also delete a phonebook information. This simple mini project for Phonebook in C also includes a downloadable Source Code for free, just find the downloadable source code below and click to start downloading. Before you start to click the download now first you must click the Run Quick Scan for secure Download.
This simple Mini Project for Phonebook in C creates an external file to store the user’s data permanently to perform file handling operations. Phonebook is an extremely straightforward small undertaking in C that can assist you with understanding the fundamental ideas of capacities, record taking care of and information structure. This application will show you how to include, list, change or alter, look and erase information to/from the record.
Individual data, for example, name, gender, father’s name, contact number, postal code, email and address are asked while including a record into the Phonebook. These records would be able to be altered, recorded, looked for and eliminated.
Anyway if you want level up your knowledge in programming especially C/C++ Programming Language, try this new article I’ve made for you Best C Projects with Source Code for Beginners Free Download 2022.
To start creating a Mini Project for Phonebook in C , make sure that you have a Code Blocks or any platform of C installed in your computer.
ABOUT PROJECT | PROJECT DETAILS |
---|---|
Project Name : | Phonebook in C |
Project Platform : | C/C++ |
Programming Language Used: | C Programming Language |
Developer Name : | itsourcecode.com |
IDE Tool (Recommended): | Dev-C++/Codeblocks |
Project Type : | Desktop Application |
Database: | Stores data in .DAT file |
Upload Date and Time: | September 22, 2020-4:19 am |
Steps on how to create a Mini Project for Phonebook in C
Time needed: 5 minutes.
Mini Project for Phonebook in C with Source Code
- Step 1: Create a new project.
First open the code blocks IDE and click “create a new project“.
- Step 2: Choose console application.
Second click the “console application” and after that click “next“.
- Step 3: Choose C language.
Third choose “C language” and click “next“.
- Step 4: Name your project.
Fourth name the project you’ve created and click “next” after that click “finish“.
- Step 5: The actual code.
You are free to copy the given source code below or download the downloadable source code given.
This function is for the phonebook attributes
In the code given below, which is for the function for the phonebook attributes use in the system.(C Mini Project for Phonebook)
1 2 3 4 5 6 7 8 9 10 11 |
struct phonebook { char fullname[35]; char add[50]; char f_name[35]; char m_name[30]; long int contact_no; char gender[8]; char email_add[100]; char postal_code[20]; }; |
This function is for the main menu
In the code given below, which is for the function used to display the main menu in the system.(C Mini Project for Phonebook)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
void menu() { system("cls"); printf("\t\t<em><strong><em>WELCOME TO PHONEBOOK</em></strong></em>***"); 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\t\n\n"); printf("\n\t\Please Enter the Number you Want to Choose"); switch(getch()) { case '1': add_info(); break; case '2': list_info(); break; case '3': exit(0); break; case '4': update_info(); break; case '5': search_info(); break; case '6': delete_info(); break; default: system("cls"); printf("\nEnter 1 to 6 only"); printf("\n Enter any key"); getch(); menu(); } } |
This function is for the add new phonebook
In the code given below, which is for the function for adding a new Phonebook record in the system.(C Mini Project for Phonebook)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
void add_info() { system("cls"); FILE *files; struct phonebook x; files=fopen("project","ab+"); printf("\n Enter Name: "); gt(x.fullname); printf("\nEnter the Address: "); gt(x.add); printf("\nEnter Father Nme: "); gt(x.f_name); printf("\nEnter Mother Name: "); gt(x.m_name); printf("\nEnter Contact Number.:"); scanf("%ld",&x.contact_no); printf("Enter Gender:"); gt(x.gender); printf("\nEnter Email Address:"); gt(x.email_add); printf("\nEnter Postal Code:"); gt(x.postal_code); fwrite(&x,sizeof(x),1,files); fflush(stdin); printf("\nNew Record Has Been Successfully Saved"); fclose(files); printf("\n\nEnter any key"); getch(); system("cls"); menu(); } |
This function is for the view of list
In the code given below, which is for the function used to view list of added records in file.(C Mini Project for Phonebook)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
void list_info() { struct phonebook x; FILE *files; files=fopen("project","rb"); if(files==NULL) { printf("\nfile opening error in listing :"); exit(1); } while(fread(&x,sizeof(x),1,files)==1) { printf("\n\n\n YOUR RECORD INFORMATION IS\n\n "); printf("\nName=%s\nAdress=%s\nFather name=%s\nMother name=%s\nMobile no=%ld\nSex=%s\nE-mail=%s\nCitizen no=%s",x.fullname,x.add,x.f_name,x.m_name,x.contact_no,x.gender,x.email_add,x.postal_code); getch(); system("cls"); } fclose(files); printf("\n Enter any key"); getch(); system("cls"); menu(); } |
This function is for the search
In the code given below, which is for the function for searches for added record by name in the system.(C Mini Project for Phonebook)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
void search_info() { struct phonebook x; FILE *files; char name[100]; files=fopen("project","rb"); if(files==NULL) { printf("\n error in opening\a\a\a\a"); exit(1); } printf("\nEnter the Name of Person you want to Search\n"); gt(name); while(fread(&x,sizeof(x),1,files)==1) { if(strcmp(x.fullname,name)==0) { printf("\n\tDetail Information About %s",name); printf("\nName:%s\naddress:%s\nFather name:%s\nMother name:%s\nMobile no:%ld\nsex:%s\nE-mail:%s\nCitision no:%s",x.fullname,x.add,x.f_name,x.m_name,x.contact_no,x.gender,x.email_add,x.postal_code); } else printf("file not found"); } fclose(files); printf("\n Enter any key"); getch(); system("cls"); menu(); } |
This function is for the delete phonebook record
In the code given below, which is for the function for the deletes record from file in the system.(C Mini Project for Phonebook)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
void delete_info() { struct phonebook x; FILE <em>files,</em>file_temp; int fl; char name[100]; files=fopen("project","rb"); if(files==NULL) { printf("CONTACT'S DATA NOT ADDED YET."); } else { file_temp=fopen("temp","wb+"); if(file_temp==NULL) printf("file opaning error"); else { printf("Enter CONTACT'S NAME:"); gt(name); fflush(stdin); while(fread(&x,sizeof(x),1,files)==1) { if(strcmp(x.fullname,name)!=0) fwrite(&x,sizeof(x),1,file_temp); if(strcmp(x.fullname,name)==0) fl=1; } fclose(files); fclose(file_temp); if(fl!=1) { printf("NO CONACT'S RECORD TO DELETE."); remove("temp.txt"); } else { remove("project"); rename("temp.txt","project"); printf("RECORD DELETED SUCCESSFULLY."); } } } printf("\n Enter any key"); getch(); system("cls"); menu(); } |
This function is for the update of record
In the code given below, which is for the function used to update added records in the system.(C Mini Project for Phonebook)
1 2 3 4 5 6 7 8 9 10 11 12 |
void update_info() { int b; FILE *files; int fl=0; struct phonebook x,y; char name[50]; files=fopen("project","rb+"); if(files==NULL) { printf("CONTACT'S DATA NOT ADDED YET."); exit(1); } else { system("cls"); printf("\nEnter CONTACT'S NAME TO MODIFY:\n"); gt(name); while(fread(&x,sizeof(x),1,files)==1) { if(strcmp(name,x.fullname)==0) { printf("\n Enter Name:"); gt(y.fullname); printf("\nEnter the Address:"); gt(y.add); printf("\nEnter Father Name:"); gt(y.f_name); printf("\nEnter Mother Name:"); gt(y.m_name); printf("\nEnter Contact Number:"); scanf("%ld",&y.contact_no); printf("\nEnter Gender:"); gt(y.gender); printf("\nEnter Email Address:"); gt(y.email_add); printf("\nEnter Postal Code\n"); gt(y.postal_code); fseek(files,-sizeof(x),SEEK_CUR); fwrite(&y,sizeof(x),1,files); fl=1; break; } fflush(stdin); } if(fl==1) { printf("\n your data id modified"); } else { printf(" \n data is not found"); } fclose(files); } printf("\n Enter any key"); getch(); system("cls"); menu(); } |
Downloadable Source Code
Summary
That’s how you create Mini Project for Phonebook in C with Source Code in your projects. You can always expand and try different ways in implementing the Mini Project for Phonebook in C in your C projects. C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on. C programming is an excellent language to learn to program for beginners. Our C tutorials will guide you to learn C programming one step at a time. In this Mini Project for Phonebook in C with Source Code is free to download and It is easy to understand and manipulate this project and use for education purpose only.
Related Articles
- Library Management System Project In Python and MySQL
- Simple Hospital Management System In C With Source Code
- Library Management System Project in VB.Net With Source Code
- Online Library Management System in PHP Source Code
- Student Management System Project in Python with Source Code
- Online Student Registration System Project in PHP
- Student Record System in C with Source Code
- Calendar In C Programming With Source Code
Inquiries
If you have any questions or suggestions about Mini Project for Phonebook in C with Source Code , please feel free to leave a comment below.
why does the code display different mobile phone when compiled?