+ 2

WHAT FUNCTION DOES THESE LINES DO: fp.open("book.dat",ios::out!ios::app);

FUNCTION OF fp.open

5th Feb 2018, 3:25 PM
Aditya Mishra
Aditya Mishra - avatar
4 Answers
+ 3
There must be some line : fstream fp; In the complete program. The 'fp' is thus a fstream object used to hold the pointer/link to the file for performing operations on it. The class encapsulates other lower level function calls to alter the files...
5th Feb 2018, 4:22 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
But why do we use fp????
5th Feb 2018, 4:20 PM
Aditya Mishra
Aditya Mishra - avatar
+ 3
Ya it's there..... THANK YOU BRO......👏👏👏👏👏
5th Feb 2018, 4:39 PM
Aditya Mishra
Aditya Mishra - avatar
+ 1
The open function of the basic_fstream class, used with fstream, ofstream and ifstream objects helps open a file for performing operations on it. Without opening, one cannot perform I/O from/to the file. The first argument is a string containing the path of the file to be opened. Here, it is 'book.dat'. The second argument specifies the open mode, or the way the file is to be opened for use (for input or output, in binary mode or not, whether to clear the file before opening or not, whether to append to the file or not, etc.). The ios::out openmode specifies that the file is to be used for writing purposes, i.e., data is going to be written to it. The ios::app openmode specifies that the file must retain the old data and the new data must not be overwritten on other data. This is ensured by moving the writing cursor to the end of the file before each write operation. For more information, kindly visit: www.cplusplus.com/reference/fstream/fstream/open
5th Feb 2018, 4:14 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar