C++ Reading file

C++ File Handling read() Function In file handling, read() function is used to read data from the file into the program. The read() uses ifstream library to read data from a file. Syntax

Example

C++ File Handling read() Function Example Reading the content of existing file ’employee.txt’.

Output: ←Prev Next→

C++ Close file

C++ File Handling close() Function A file which is opened while reading or writing in file handling must be closed after performing an action on it. The close() function is used to close the file currently associated with the object. The close() uses ofstream library to close the file. Syntax

Example

C++ File Handling close() Function Example …

Read moreC++ Close file