Simple CRUD (Add, Edit, Delete and View) in C++ using .TXT(text) file as database

0
2967

The tutorial that we will learn right now is similar to the previous article CRUD in Java that manipulates the record from the text(.txt) file which is our flat file database. But the difference is that we will use C++ as our language. Just like Java, C++ is also an object-oriented language which you can use classes and methods to beautify and optimize the code.

In this tutorial, we will not use C++ as object-object oriented but rather we will use procedural programming to finish the add, edit, delete and view of record in text(.txt) file.

The sample record inside our database will be separated by comma(CSV). What we are going to create is a simple phonebook management system.

First, we will create our menu for us to navigate to every module of the CRUD.

Now, we will start the coding of our CRUD by calling first the necessary libraries.

The code for our add record in text(.txt) file will look like this.

For our view all record, we will query all the data from the text(.txt) file and put it in an array to easily display the data.

For our search record, we will get the specific record and analyze if it contains what we are searching.

Below are the sample screenshots of the Simple CRUD in C++ using (text).TXT file as flat file database.

C++ CRUD Menu screenshot

CRUD menu for flat file manipulation in Java

C++ Add Record screenshot

Adding record module for flat file manipulation in Java

C++ View Record screenshot

View record module for flat file manipulation in Java