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.
- 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.txton top of that
| 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 |
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.
Requires CMake and a C11-compatible compiler.
mkdir build && cd build
cmake ..
cmake --build .This produces the AddressBook_NewDesign executable.
./AddressBook_NewDesignYou'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.
Contacts are stored one per line in contacts.txt as:
name,phone,email
- Hardcoded file path:
file.ccurrently pointsFILE_PATHto 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 checkMAX_CONTACTSbefore 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'ssortCriteriaparameter 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.
SHIVANANDU.K