![]() If you open file using ofstream class then file is default opened for writing purpose. Note : When you open file using ifstream class then file is default opened for reading. Syntax: ifstream object_name.open(“file_name”) In C++, the ifstream class is used to realize the file reading operation. This data type usually represents a file stream and has both ofstream and ifstream functions, which means it can create files, write information to files and read information from files.įor file handling in C++, the header files iostream and fstream must be included in the C++ source code file. ![]() This data type represents the input file stream, which is used to read information from the file. This data type represents the output file stream, which is used to create files and write information to them. This requires the use of another standard library fstream in C++, which defines three new data types: Now if we have to read streams from and write streams to files. We have commonly used the iostream standard library, which provides the cin and cout methods for reading streams from standard input and writing streams to standard output, respectively.
0 Comments
Leave a Reply. |