Lecture 10
Lecture 10
OOP
Beenish Urooj
Files (Streams)
• File: The information / data stored under a specific name on a storage device, is called a
file.
• Stream: It refers to a sequence of bytes.
• Text file: It is a file that stores information in ASCII characters. In text files, each line
of text is terminated with a special character known as EOL (End of Line) character or
delimiter character. When this EOL character is read or written, certain internal
translations take place.
• Binary file: It is a file that contains information in the same format as it is held in
memory. In binary files, no delimiters are used for a line and no translations occur here.
C++ Streams
• File Handling concept in C++ language is used for store a data permanently in
computer. Using file handling we can store our data in Secondary memory
(Hard disk).
We can read data from file and write data to file in three
ways.
• Reading
or writing characters using get() and put()
member functions.
• Reading or writing formatted I/O using insertion
operator (<<) and extraction operator ( >> ).
• Reading
or writing object using read() and write()
member functions.
Example
This creates an object of ifstream class named input to read data from a file.