Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
30 views
9 pages
PF Source Code
C programming project code for address book code .
Uploaded by
zunairatariq985
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save pf source code For Later
Download
Save
Save pf source code For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
30 views
9 pages
PF Source Code
C programming project code for address book code .
Uploaded by
zunairatariq985
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save pf source code For Later
Carousel Previous
Carousel Next
Download
Save
Save pf source code For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 9
Search
Fullscreen
Title: File Management System
( Creating a Address book in C )
Source code:
#include <stdio.h>
#include <string.h>
struct Person {
char name[30];
char phone[30];
char email[30];
char address[30];
};
void addressbook(){
printf("\n--- Contact Management System ---\n");
printf("1. Add Contact\n");
printf("2. View all Contacts\n");
printf("3. View a specific contact\n");
printf("4. Delete Contact\n");
printf("5.change a contact\n");
printf("6. delete all contacts \n");
printf("7. Search a contact\n");
printf("8. Exit ");
}
void addContact() {
FILE *file = fopen("C:\\files\\contacts.txt", "a");
if (file == NULL)
{
perror("Error opening file");
return;
}
struct Person newPerson;
printf("Enter name: ");
scanf("%s", &newPerson.name);
printf("Enter phone number: ");
scanf("%s",&newPerson.phone);
printf("Enter email: ");
scanf("%s", &newPerson.email);
printf("Enter address: ");
scanf("%s", &newPerson.address);
fprintf(file, "%s %s %s %s ", newPerson.name, newPerson.phone, newPerson.email,newPerson.address);
fclose(file);
printf("Contact added successfully.\n");
}
void viewContacts() {
FILE *file = fopen("C:\\files\\contacts.txt", "r");
if (file == NULL) {
perror("Error opening file");
return;
}
struct Person currentPerson;
printf("Contacts:\n");
while (fscanf(file, "%s %s %s %s", ¤tPerson.name, ¤tPerson.phone,
¤tPerson.email,¤tPerson.address) != EOF) {
printf(" \n%s\n%s\n%s\n%s\n", currentPerson.name, currentPerson.phone,
currentPerson.email,currentPerson.address);
}
fclose(file);
}
void deleteContact() {
char name[30];
printf("Enter name to delete: ");
scanf("%s", &name);
FILE *file = fopen("C:\\files\\contacts.txt", "r");
FILE *tempFile = fopen("C:\\files\\temp.txt", "w");
struct Person currentPerson;
int found = 0;
while (fscanf(file, "%s %s %s %s", ¤tPerson.name, ¤tPerson.phone, ¤tPerson.email,
¤tPerson.address) != EOF)
{
if (strcmp(currentPerson.name, name) != 0)
{
fprintf(tempFile, "%s %s %s %s\n", currentPerson.name, currentPerson.phone,
currentPerson.email,currentPerson.address);
}
else {
found = 1;
}
}
fclose(file);
fclose(tempFile);
remove("C:\\files\\contacts.txt");
rename("C:\\files\\temp.txt", "C:\\files\\contacts.txt");
if (found)
{
printf("Contact '%s' deleted successfully.\n", name);
}
else {
printf("Contact '%s' not found.\n", name);
}
}
void deleteall() {
FILE *file = fopen("C:\\files\\contacts.txt", "r");
FILE *fprt = fopen("C:\\files\\temp.txt", "w");
fclose(file);
fclose(fprt);
remove("C:\\files\\contacts.txt");
rename("C:\\files\\temp.txt", "C:\\files\\contacts.txt");
printf("Contacts deleted successfully.\n");
}
void view(){
FILE *f = fopen("C:\\files\\contacts.txt", "r");
if (f == NULL)
{
perror("Error opening file");
return;
}
char nameToFind[30];
printf("Enter name to find: ");
scanf("%s", &nameToFind);
struct Person contact;
int found = 0;
while (fscanf(f, "%s %s ", &contact.name, &contact.phone)==2) {
if (strcmp(contact.name, nameToFind) == 0)
{
printf("Name: %s\nPhone: %s\n ", contact.name, contact.phone);
found = 1; }
}
if (found!=1)
{ printf("Contact not found\n");
}
fclose(f);
}
void editContact(){
struct Person contact;
FILE *f=fopen("C:\\files\\contacts.txt","r");
FILE *fprt=fopen("C:\\files\\tempFile.txt","w");
char name[30];
int found=0;
printf("enter the name to edit\n");
scanf("%s",&name);
while(fscanf(f, "%s %s %s %s",&contact.name,&contact.phone,&contact.email,&contact.address) == 4){
if(strcmp(contact.name,name)==0)
{
printf("enter new contact\n");
scanf("%s",&contact.name);
printf("enter new phone\n");
scanf("%s",&contact.phone);
printf("enter new email\n");
scanf("%s",&contact.email);
printf("enter new address\n");
scanf("%s",&contact.address);
found=1;
}
fprintf(fprt," %s %s %s %s ",contact.name,contact.email,contact.phone,contact.address);
}
fclose(f);
fclose(fprt);
remove("C:\\files\\contacts.txt");
rename("C:\\files\\tempFile.txt", "C:\\files\\contacts.txt");
}
void search(){
FILE*f=fopen("C:\\files\\contacts.txt","r");
struct Person contact;
char name[30];
printf("enter name to search");
scanf("%s",name);
while(fscanf(f, "%s %s %s %s",&contact.name,&contact.phone,&contact.email,&contact.address)==4){
if(strcmp(contact.name,name)==0
{ printf("%s %s %s %s",contact.name,contact.phone,contact.email,contact.address);
}
}
}
int main() {
int choice;
char name[30];
do {
addressbook();
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1: addContact();
break;
case 2: viewContacts();
break;
case 3: view();
break;
case 4: deleteContact();
break;
case 5: editContact();
break;
case 6: deleteall();
break;
case 7: search();
break;
case 8: printf("Exiting program. Goodbye!\n");
break;
default:
printf("Invalid choice. Please enter a valid option.\n");
}
} while (choice != 8);
return 0; }
Output:
Adding new contacts:
View all contacts:
View a specific contact:
Delete a specific contact:
Delete all contacts:
Adding anew contact +editing a new
contact:
Searching a contact:
Exiting the program:
You might also like
Data Structure Using C' Proposal On Telephone Directory Using Doubly-Linked List
PDF
100% (1)
Data Structure Using C' Proposal On Telephone Directory Using Doubly-Linked List
23 pages
exp7
PDF
No ratings yet
exp7
9 pages
Ankur c project.docx_20250502_111447_0000_organized (1)
PDF
No ratings yet
Ankur c project.docx_20250502_111447_0000_organized (1)
4 pages
text
PDF
No ratings yet
text
3 pages
contact management.1
PDF
No ratings yet
contact management.1
15 pages
AIM
PDF
No ratings yet
AIM
12 pages
Index SR No Topic Page No
PDF
No ratings yet
Index SR No Topic Page No
13 pages
ds[1]
PDF
No ratings yet
ds[1]
20 pages
Address Book Program in C
PDF
75% (4)
Address Book Program in C
15 pages
#Include #Include #Include #Include #Include #Include
PDF
No ratings yet
#Include #Include #Include #Include #Include #Include
6 pages
Phone Book 2 Asign PRJ
PDF
No ratings yet
Phone Book 2 Asign PRJ
6 pages
ספר טלפונים ב - c++
PDF
No ratings yet
ספר טלפונים ב - c++
6 pages
Contact Management (1)
PDF
No ratings yet
Contact Management (1)
15 pages
JKKH
PDF
No ratings yet
JKKH
23 pages
Real Time Application in DSA
PDF
No ratings yet
Real Time Application in DSA
18 pages
CSE202 Mini Project Report
PDF
No ratings yet
CSE202 Mini Project Report
13 pages
Phonebook Link List Adt, Stack Adt
PDF
No ratings yet
Phonebook Link List Adt, Stack Adt
7 pages
Contact Management System - C Programming Project by Raghu
PDF
100% (1)
Contact Management System - C Programming Project by Raghu
25 pages
Contact Management Project
PDF
No ratings yet
Contact Management Project
9 pages
DSU Microproject Proposal
PDF
No ratings yet
DSU Microproject Proposal
25 pages
Eyob DSA Group Assign
PDF
No ratings yet
Eyob DSA Group Assign
14 pages
DSU MICRO PROJECT Final
PDF
100% (1)
DSU MICRO PROJECT Final
23 pages
Structure in C
PDF
No ratings yet
Structure in C
3 pages
Case Study Mobile Contact Application Tomorrow
PDF
No ratings yet
Case Study Mobile Contact Application Tomorrow
10 pages
NANDINI
PDF
No ratings yet
NANDINI
3 pages
Computer Science Project On Address Book
PDF
100% (2)
Computer Science Project On Address Book
19 pages
Soham DSU
PDF
No ratings yet
Soham DSU
24 pages
Phonebook
PDF
No ratings yet
Phonebook
10 pages
DSMinor Project
PDF
No ratings yet
DSMinor Project
16 pages
Mark Anthony Legaspi December 10, 2018 Bsit - 1A
PDF
No ratings yet
Mark Anthony Legaspi December 10, 2018 Bsit - 1A
5 pages
Lab Project Report Template - CSE
PDF
No ratings yet
Lab Project Report Template - CSE
13 pages
PhoneBook Source Code using Data Structure_C
PDF
No ratings yet
PhoneBook Source Code using Data Structure_C
8 pages
Ass9 PDF
PDF
No ratings yet
Ass9 PDF
2 pages
Telephone Directory C++ Code
PDF
No ratings yet
Telephone Directory C++ Code
4 pages
OOP Assignment 2
PDF
No ratings yet
OOP Assignment 2
11 pages
PHONEBOOK.cpp oops
PDF
No ratings yet
PHONEBOOK.cpp oops
4 pages
File Handling / File Operations /data Files
PDF
No ratings yet
File Handling / File Operations /data Files
14 pages
c rec
PDF
No ratings yet
c rec
99 pages
Foc by Julion
PDF
No ratings yet
Foc by Julion
18 pages
Cse115 Lab Manual 19 File
PDF
No ratings yet
Cse115 Lab Manual 19 File
3 pages
CD New File
PDF
No ratings yet
CD New File
9 pages
SAYED MIZANUR RAHMAN (ASSIGNMENT-6)
PDF
No ratings yet
SAYED MIZANUR RAHMAN (ASSIGNMENT-6)
10 pages
Document 2
PDF
No ratings yet
Document 2
6 pages
Employer Record System: By, Arjun Acharya Samarth M.S Shashank
PDF
No ratings yet
Employer Record System: By, Arjun Acharya Samarth M.S Shashank
8 pages
Contact Manage Ment System
PDF
No ratings yet
Contact Manage Ment System
18 pages
Ex - No:10b Sequential Access File AIM
PDF
No ratings yet
Ex - No:10b Sequential Access File AIM
4 pages
SS File
PDF
No ratings yet
SS File
28 pages
Isfileexists
PDF
No ratings yet
Isfileexists
25 pages
Document 2
PDF
No ratings yet
Document 2
6 pages
Submitted By-: Devavrat Singh AND Chandan Kumar
PDF
No ratings yet
Submitted By-: Devavrat Singh AND Chandan Kumar
9 pages
11
PDF
No ratings yet
11
31 pages
Project of Telephone Directory
PDF
No ratings yet
Project of Telephone Directory
15 pages
Program of Telephone Directory - C++ Programming Tutorial - Codepoc - Io
PDF
0% (1)
Program of Telephone Directory - C++ Programming Tutorial - Codepoc - Io
5 pages
C Project Code
PDF
No ratings yet
C Project Code
63 pages
Krishna Gupta Himanshu Chavan: Suman Educational Trust's Dilkap Research Institute of Engineering and Management Studies
PDF
No ratings yet
Krishna Gupta Himanshu Chavan: Suman Educational Trust's Dilkap Research Institute of Engineering and Management Studies
19 pages
Contact Management System: Project
PDF
No ratings yet
Contact Management System: Project
7 pages
206MiniAss4x2023Winter
PDF
No ratings yet
206MiniAss4x2023Winter
7 pages
A File Named As "Tele - DAT " Contains The Records Name, Address and Telephone Number - Write A Command To Update The Record. // Filename: //U1Chap07/ch07 - 420.CPP
PDF
No ratings yet
A File Named As "Tele - DAT " Contains The Records Name, Address and Telephone Number - Write A Command To Update The Record. // Filename: //U1Chap07/ch07 - 420.CPP
3 pages
Computer Engineering Laboratory Solution Primer
From Everand
Computer Engineering Laboratory Solution Primer
Karan Bhandari
No ratings yet
C Language Programming Codes
From Everand
C Language Programming Codes
Durgesh
No ratings yet
dotnetconf2024-Simplify the development of distributed applications with .NET Aspire
PDF
No ratings yet
dotnetconf2024-Simplify the development of distributed applications with .NET Aspire
57 pages
HP Journal 8710 An Infrared Link For Low-Cost Calculators and Printers
PDF
No ratings yet
HP Journal 8710 An Infrared Link For Low-Cost Calculators and Printers
5 pages
Data Sheet: 83C145 83C845 83C055 87C055
PDF
No ratings yet
Data Sheet: 83C145 83C845 83C055 87C055
41 pages
Sierra Wireless Airlink LS300 Router Setup Using Inductive Automation Template
PDF
No ratings yet
Sierra Wireless Airlink LS300 Router Setup Using Inductive Automation Template
3 pages
Asymptotic Notation PDF
PDF
No ratings yet
Asymptotic Notation PDF
22 pages
Terraform Certified
PDF
100% (3)
Terraform Certified
121 pages
COA 2nd Unit Full
PDF
No ratings yet
COA 2nd Unit Full
98 pages
Exp 2_Workshop and Tooling-1
PDF
No ratings yet
Exp 2_Workshop and Tooling-1
11 pages
Release Notes For FEKO Suite 7.0
PDF
No ratings yet
Release Notes For FEKO Suite 7.0
77 pages
Power BI and SAP BW
PDF
No ratings yet
Power BI and SAP BW
59 pages
Mid 2
PDF
No ratings yet
Mid 2
12 pages
6-12 Periodic Tests For Term 2 (2022-23)
PDF
No ratings yet
6-12 Periodic Tests For Term 2 (2022-23)
1 page
Linux Magazine 241 2020-12 USA
PDF
100% (1)
Linux Magazine 241 2020-12 USA
100 pages
Introduction To VB (Lesson One)
PDF
No ratings yet
Introduction To VB (Lesson One)
22 pages
MAD Lab Exp-8 PCE18IT016
PDF
No ratings yet
MAD Lab Exp-8 PCE18IT016
4 pages
Softice Tutorial From Mexelite Cracking Group
PDF
No ratings yet
Softice Tutorial From Mexelite Cracking Group
10 pages
CH 10 Feeback
PDF
No ratings yet
CH 10 Feeback
127 pages
7TH_UNIT 4-21EC74H6_CA
PDF
No ratings yet
7TH_UNIT 4-21EC74H6_CA
67 pages
Systems Analysis and Design in A Changing World, 7th Edition - Chapter 6 ©2016. Cengage Learning. All Rights Reserved. 1
PDF
No ratings yet
Systems Analysis and Design in A Changing World, 7th Edition - Chapter 6 ©2016. Cengage Learning. All Rights Reserved. 1
24 pages
Company Profile PT. Javan Cipta Solusi Redesign 2022
PDF
No ratings yet
Company Profile PT. Javan Cipta Solusi Redesign 2022
69 pages
Ad Coursework
PDF
No ratings yet
Ad Coursework
15 pages
a52ab2e5.3459754SWYM_UUID_PREFIXDesktop-heap-and-graphic-resources-per-SW-KB
PDF
No ratings yet
a52ab2e5.3459754SWYM_UUID_PREFIXDesktop-heap-and-graphic-resources-per-SW-KB
4 pages
Kingston EMMC16G IB29 70H01 v1 1-3236273
PDF
No ratings yet
Kingston EMMC16G IB29 70H01 v1 1-3236273
25 pages
2020 Kernel History Report 082720
PDF
No ratings yet
2020 Kernel History Report 082720
25 pages
Flashstack With Cisco Ucs and Pure Storage Flasharray//M For 5000 Vmware Horizon View 6.2 Users
PDF
No ratings yet
Flashstack With Cisco Ucs and Pure Storage Flasharray//M For 5000 Vmware Horizon View 6.2 Users
255 pages
Ci 2022 0006 Mobilogix MT2000 Protocol Over The Air 01 07 2022 V1 15
PDF
No ratings yet
Ci 2022 0006 Mobilogix MT2000 Protocol Over The Air 01 07 2022 V1 15
58 pages
Mtech Ai ML
PDF
No ratings yet
Mtech Ai ML
22 pages
Digital Forensics LAB Assignment 03: Ma'Am Maira Sultan
PDF
No ratings yet
Digital Forensics LAB Assignment 03: Ma'Am Maira Sultan
22 pages
605 Software Engineering
PDF
No ratings yet
605 Software Engineering
11 pages
Architecture Description Languages
PDF
No ratings yet
Architecture Description Languages
6 pages