Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Address Book (C)

A simple command-line address book manager written in C. Contacts are held in memory during a session and can be saved to / loaded from a text file.

System Description and Block Diagram

image

Features

  • Create contact — add a name, phone number, and email
  • Search contact — find a contact by name, phone, or email (substring match)
  • Edit contact — search for a contact, then edit its name, phone, or email
  • Delete contact — search for a contact, then remove it from the list
  • List contacts — print all contacts in a table
  • Save contacts — write all contacts to contacts.txt
  • Starts up pre-populated with 10 dummy contacts, then loads any saved contacts from contacts.txt on top of that

Project Structure

File Purpose
main.c Entry point — displays the menu and dispatches choices
contact.c/h Core contact operations: create, search, edit, delete, list
file.c/h Save/load contacts to/from contacts.txt
populate.c/h Seeds the address book with dummy contacts on startup
contacts.txt Persisted contact data (name,phone,email per line)
CMakeLists.txt Build configuration

Data Model

typedef struct {
    char name[50];
    char phone[20];
    char email[50];
} Contact;

typedef struct {
    Contact contacts[100];
    int contactCount;
} AddressBook;

Up to MAX_CONTACTS (100) contacts are supported.

Building

Requires CMake and a C11-compatible compiler.

mkdir build && cd build
cmake ..
cmake --build .

This produces the AddressBook_NewDesign executable.

Running

./AddressBook_NewDesign

You'll see a menu:

Address Book Menu:
1. Create contact
2. Search contact
3. Edit contact
4. Delete contact
5. List all contacts
6. Save contacts
7. Exit

Enter the number for the action you want, and follow the prompts.

Contact File Format

Contacts are stored one per line in contacts.txt as:

name,phone,email

Known Issues / Limitations

  • Hardcoded file path: file.c currently points FILE_PATH to a fixed Windows path (C:\Users\snk_win\CLionProjects\Address_Book\contacts.txt). This must be updated (or made relative/portable) to run on other machines or operating systems.
  • No overflow check on create: createContact() doesn't check MAX_CONTACTS before adding, so the address book can overflow if it's full.
  • Choosing "Exit" (7) doesn't save automatically — use "Save contacts" (option 6) first, or contacts entered in the session will be lost.
  • listContacts's sortCriteria parameter is currently unused — contacts are always listed in insertion order.
  • Input for name/phone/email is restricted to specific character sets and fixed max lengths (see contact.c), so unusual characters or long values will be rejected or truncated.

Author

SHIVANANDU.K

About

A simple command-line address book manager written in C. Contacts are held in memory during a session and can be saved to / loaded from a text file.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages