Sanjivani Rural Education Society’s
Sanjivani College of Engineering, Kopargaon-423 603
(An Autonomous Institute, Affiliated to Savitribai Phule Pune University, Pune)
NAAC ‘A’ Grade Accredited, ISO 9001:2015 Certified
Department of Computer Engineering
(NBA Accredited)
Prof. I. B. Tirse
Assistant Professor
E-mail :tirseishwaricomp@sanjivani.org.in
Contact No: 7507113718
Subject- Object Oriented Programming (CO212)
Unit 5 – Files and Streams
Topic – 5.1 Data Hierarchy, Stream and Files, Stream
Classes
DEPARTMENT OF COMPUTER ENGINEERING , SCOE,KOPARGAON 2
3
• All programs we looked earlier:
Introduction to files


input data from the keyboard.
output data to the screen.
• Output would be lost as soon as we exit from the program.
• How do we store data permanently?


We can use secondary storage device.
Data is packaged up on the storage device as
data structures called files.
DEPARTMENT OF COMPUTER ENGINEERING , SCOE,KOPARGAON 3
4
Streams Usage
• We have used streams already
 c i n
Input from stream object connected to keyboard
cout
Output to stream object connected to screen
• C a n define other streams
 To or from files
Used similarly as cin, cout
DEPARTMENT OF COMPUTER ENGINEERING , SCOE,KOPARGAON 4
5
File input and output streams
DEPARTMENT OF COMPUTER ENGINEERING , SCOE,KOPARGAON 5
6
Streams
 File Input Stream – reads data from disk file to the program.
 The I/O system of C++ contains following classes :
 File output Stream – writes data to the disk file from the program.



ofstream – provides output operations on files
fstream – supports for simultaneous input and
output operations on files
ifstream – provides input operations on files
DEPARTMENT OF COMPUTER ENGINEERING , SCOE,KOPARGAON 6
Stream Classes
DEPARTMENT OF COMPUTER ENGINEERING , SCOE,KOPARGAON 7
The Data Hierarchy
7
 From smallest to largest
 Bit (binary digit)
 1 or 0
 Everything in computer ultimately represented as
bits
 Character set
 Digits, letters, symbols used to represent data
 Every character represented by 1's and 0's
 Byte: 8 bits
 Can store a character (char)
DEPARTMENT OF COMPUTER ENGINEERING , SCOE,KOPARGAON 8
The Data Hierarchy (contd.)
8
 From smallest to largest (continued)
Field: group of characters with some meaning
e.g., Your name
Record: group of related fields
 struct or class in C++
File: group of related records
Payroll for entire company
Database: group of related files
Payroll, accounts-receivable.
Thank You..
DEPARTMENT OF COMPUTER ENGINEERING , SCOE,KOPARGAON 9

5.1 Data hierarchy, Stream and files, Stream Classes.pptx

  • 1.
    Sanjivani Rural EducationSociety’s Sanjivani College of Engineering, Kopargaon-423 603 (An Autonomous Institute, Affiliated to Savitribai Phule Pune University, Pune) NAAC ‘A’ Grade Accredited, ISO 9001:2015 Certified Department of Computer Engineering (NBA Accredited) Prof. I. B. Tirse Assistant Professor E-mail :tirseishwaricomp@sanjivani.org.in Contact No: 7507113718 Subject- Object Oriented Programming (CO212) Unit 5 – Files and Streams Topic – 5.1 Data Hierarchy, Stream and Files, Stream Classes
  • 2.
    DEPARTMENT OF COMPUTERENGINEERING , SCOE,KOPARGAON 2 3 • All programs we looked earlier: Introduction to files   input data from the keyboard. output data to the screen. • Output would be lost as soon as we exit from the program. • How do we store data permanently?   We can use secondary storage device. Data is packaged up on the storage device as data structures called files.
  • 3.
    DEPARTMENT OF COMPUTERENGINEERING , SCOE,KOPARGAON 3 4 Streams Usage • We have used streams already  c i n Input from stream object connected to keyboard cout Output to stream object connected to screen • C a n define other streams  To or from files Used similarly as cin, cout
  • 4.
    DEPARTMENT OF COMPUTERENGINEERING , SCOE,KOPARGAON 4 5 File input and output streams
  • 5.
    DEPARTMENT OF COMPUTERENGINEERING , SCOE,KOPARGAON 5 6 Streams  File Input Stream – reads data from disk file to the program.  The I/O system of C++ contains following classes :  File output Stream – writes data to the disk file from the program.    ofstream – provides output operations on files fstream – supports for simultaneous input and output operations on files ifstream – provides input operations on files
  • 6.
    DEPARTMENT OF COMPUTERENGINEERING , SCOE,KOPARGAON 6 Stream Classes
  • 7.
    DEPARTMENT OF COMPUTERENGINEERING , SCOE,KOPARGAON 7 The Data Hierarchy 7  From smallest to largest  Bit (binary digit)  1 or 0  Everything in computer ultimately represented as bits  Character set  Digits, letters, symbols used to represent data  Every character represented by 1's and 0's  Byte: 8 bits  Can store a character (char)
  • 8.
    DEPARTMENT OF COMPUTERENGINEERING , SCOE,KOPARGAON 8 The Data Hierarchy (contd.) 8  From smallest to largest (continued) Field: group of characters with some meaning e.g., Your name Record: group of related fields  struct or class in C++ File: group of related records Payroll for entire company Database: group of related files Payroll, accounts-receivable.
  • 9.
    Thank You.. DEPARTMENT OFCOMPUTER ENGINEERING , SCOE,KOPARGAON 9