SUMMARY
- File is a sequential collection of data items. It can be stored on and retrieved from a disk
- Text file consists only of characters. It is line oriented. Line length is not fixed. All program files (source code) are text files.
- Binary files store data in binary form. (Not in textual form). These files have certain advantages over text files. Program files are binary files.
- Opening of Text files: two possible styles.
Defining an object of a class istream and using method open() with filename
istream f1;
f1.open(file_name);
creating istream object using particular constructor
istream f1(file_name);
- Reading a text file: (1) Using extraction operator; (2) using get(ch) function and (3) using getline() function.
- Writing a text file: (1) using ...
Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.