This program allows you to manage a database of persons. You can add new persons, view existing persons, save the database to a file, load the database from a file, search for persons by index, and delete persons from the database. 🗃️
To run this program, you need to have a C++ compiler installed on your system. The program uses standard C++ libraries and does not require any additional dependencies. ⚙️
- Compile the program using a C++ compiler. For example, you can use the following command with
g++
: 🛠️
g++ -o persondb main.cpp
- Run the compiled program:
▶️
./persondb
- Follow the menu options to perform various operations on the person database. 📋
The program provides the following menu options:
-
Add person: Allows you to add a new person to the database. You need to provide the person's name, surname, age, and phone number. ➕
-
Show persons: Displays all the persons in the database. It shows the person's index, name, surname, age, and phone number. 👀
-
Save Database to file: Saves the current state of the person database to a file named dataBase.txt. 💾
-
Load Database from file: Loads the person database from the dataBase.txt file. Any existing data in the database will be replaced. 📥
-
Search Database from database buffer: Displays person of choosen index.
-
Delete person from database: Allows you to delete a person from the database based on their index. You need to provide the index of the person you want to delete. ❌
The person database is stored in memory using a vector of Person objects. Each Person object contains the following information:
ID: An automatically assigned unique identifier for the person. Name: The person's name. Surname: The person's surname. Age: The person's age. Phone number: The person's phone number.
The person database can be saved to and loaded from a file named dataBase.txt. The file format is as follows:
<number of persons>
<name>
<surname>
<age>
<phone number>
Each person's information is stored sequentially, with each field on a separate line. The number of persons in the database is stored at the beginning of the file.
When deleting a person, the program saves the updated database to the file automatically. The program expects the database file to be present in the same directory as the program executable. If the file is not found, an error message will be displayed. Feel free to modify and extend this program according to your needs. 🛠️