Posts

MODIFY

Image
Modify operation. In this blog I have explained the function modify().  Modify operation is used just to modify the existing data in the file. For example suppose there is one entry having a name of book "Data structure through C" in the file and we want to modify the name of the author. For that first we have to search for that book in the file and then we can modify the name of the author. In the same way we can modify any of the field related to the book.  Now we will see how to program this function. Before finding the details of the book we want to modify we have to check whether the previous copying() function is over or not. If it is over then only we can modify the details. void modify()   {     if(q==0)       {         copying();         q=1;       } As we can see the function modify() starts with if loop. We have take one flag 'q' whose value is 0 unti...

INSERTION

Image
Insertion In this blog I have explained the insertion() function in detail. Aim of our project is to create the database of the books in the library. We have to maintain all the records and details of all the books.  So the important thing is to insert the data into the file in well structured format.  To do this we have check first that the file is opened successfully or not.For that we put condition in if loop ' file.is_open()'. This will return true if file is opened successfully otherwise it will return false. Once it enters in if loop it will take all the inputs from the user like name of the book, name of the author, publication, number of pages etc. void insertion()     {   fstream file;         file.open("cp.txt",ios::out|ios::app);         books b1; Function starts with creating the object of fstream class. As we have to write in the file we have to op...

WRITING TO FILE

Image
WRITING function is used to write to the file which is one of the basic need of our program. This function is expected to be used every time we change anything in the data-set which is first opened in append mode in our program. In the above part of code, in void writing() first we open our file and then check for error in opening the file. If there is no error in opening the file then we proceed for the further code. After checking for availability of file, we write the data stored in our array yash to the file. To do so, a variable k is initialized to 0 which is incremented till the top which tells the end of the array yash i.e. taking all the entries. file.setf(ios::left,ios::adjustfield); file.width(20);                        Above to lines are used to align text to left side and first attribute of each line have reserved 20 character space fir itself (just for the sake of alignment) as shown below. ...

DELETION CONTINUED

Image
I n this blog we are going to see the further implementation of the copying function and how we can use it to  perform the deletion operation. The first step is to open the file in which the data of the books is stored.For this we create a object of the fstream class  named file which is the stream name to access the particular file.             top=-1;      fstream file;      file.open("cp.txt"); Now we check if the file has been successfully opened or not and then we proceed further.For this we use the function   file.is_open() function which returns true for successful opening of the file and false for any error in opening the file. if(file.is_open())                     {                        cout<<endl<<"file opened successfully\n";         ...

DELETION

In this blog we are going to see how a user can delete a specific data that is a particular book from the  database.This is a operation which can only be performed by special user so this is user specific and can only be  performed by the admin. So before jumping directly on to the deletion operation we are going to discuss a pre-required step that is to copy  the data from the secondary memory or the hard disk of the system to the program memory.This is an important step in  the whole project as from this operation we can perform the rest of the operations. The data from the text file in c++ cannot be deleted directly as we do in normal writing that is just to enter back space  and the required data is deleted.This cannot happen because the user cannot directly access the file directly.The  files in cpp are handled using streams and this stream is attached to a particular file.The stream is the one which performs  the required operation on the...

Menu driven program

Image
MENU DRIVEN PROGRAM  In the previous blog of this series we have came to know basic framework of our project.It includes the functionalities with which a user is going to work and his/her scope in accessing those functionalities etc. In this blog we are going to discuss the menu driven program of our project. Basically it defines our project .        So Menu driven program is a program that obtains input from a user by displaying a list of options which is nothing but the menu from which the  user indicating his or her choice .There are many examples of menu driven program. Let us take example of bank cash dispensers.In that case single keys are pressed to indicate the type of transaction whether a receipt is wanted with the cash, or if a statement of the bank balance is required and with many, a single key is pressed to indicate the amount of money required. There are advantages of menu driven program.Firstly, because input is ...

Introduction of project

Welcome to the blog series once again.Till now we discussed about how to develop a project or a system and  some basic fundamentals. From this blog and the forthcoming ones we will be extensively discussing on the project. AIM-The aim or the topic of the project through which we are going to show the implementation of basic  properties of sql in cpp is a simple library management project where the database would be of the books present in the library and some attributes associated with it.The main aim of this project is to demonstrate  the use of sql functionalities using object orientated in cpp. design definition:-   1.Implementation is done in cpp using code blocks IDE.   2.Data is stored in a text file as the database.   3.User is cateogarised as Admin and student.   4.security check must be performed to ensure the correct user via password check.    5.According to the User cateogary function...