File management is required everywhere. C++ makes its own database file in machine language and we use it according to our own convenience. Here all data input by the user is treated like string. Sometimes we call it stream or flow of data.
First of all we know few functions which are used in file handling.
These are basic File handling functions in C++
Use of this function is to open many files to be used as continuous stream object. For example object.open(“filename”);
It is use for closing a file. For example object.close()
This function access one line data. For example object.getline(Line, Size);
Use of this function is to know that content pointer inside a file is in last of the of the file. For example if(obj.eof())
This is used to know that whether content pointer inside the file is in starting of data. For example if(obj.bof())
The work of this function is to bring get pointer to a specific location. For example obj.seekg(5)
This function brings put pointer to a specific location. For example obj.seekp(10)
It brings get pointer to the correct location.
It brings put pointer to the correct location.
This function read data in binary format.
This function write data in binary format.
It tells the size of data to be used.
It returns true if input or output operation in a file fails.
This type of object helps in reading data from file.
This type of object helps in writing data in file.
This type of object helps in reading or writing from object file.