SlideShare a Scribd company logo
M.SUJITHA,
M.SC Student,
N.S College, Theni.
C++ STREAM CLASSES
 The features that supports to format the console
I/O operations are:
◦ Ios class functions and flags
◦ Manipulators
◦ User-defined output functions
IOS CLASS FUNCTIONS AND FLAGS:
It consists of large number of member
functions that is used to format the output in
number of ways.
 MANIPULATORS:
These are the special functions that are
included in the I/O statements to format the parameters
of a stream.
 DEFINING FIELD WIDTH:
◦ It is used to define the width of the field.
◦ Can be defined using width();
SETTING PRECISION:
 It is used to specify the to be displayed after the decimal
point.
FILLING AND PADDING:
 It is used to print the values using the larger field widths.
 It can be declared by,
cout.fill();
It is used for defining the input and
output in various forms.
Overloaded Operators >> and <<:
• It is used to give the I/O
• The >> is overloaded in istream class
• The << is overloaded in ostream class
Ex:
cin>>item1>>item2;
put() and get() Functions:
◦ It is used for the input and output .
◦ Put(c) is used to give the input
◦ Get(c) is used to get the output
Getline() and write() Functions:
• The getline() function reads a whole line of the
text and ends with a newline character.
• This function can be invoked by,
cin.getline (line,size);
• The writeline() function reads a whole line of the
text and displays an entire line.
• This function can be invoked by,
cout.write (line,size);
 The header file iomanip provides a set of functions called
manipulators which can be used to manipulate the output
formats.
 They provide the same features as that of the ios member
function and flag.
 Two or more manipulators can be,
 Cout<<manip1<<manip1<<manip<<item;
 Cout<<manip1<<item1<<manip2<<item2;
 The large amount of Data can be handled using
some devices such as floppy disk or hard disk to
store those datas.
 These datas are stored in these devices called
FILES.
 The Programs can be designed to perform the
read and write operations on those files.
 Kinds of Data Communication:
◦ Data Transfer between the console unit and the
program.
◦ Data Transfer between the program and a Diskfile.
 The I/O system contains a set of classes that define the
file handling methods.
 These includes ifstream, ofstream and fstream.
 These classes are derived from fstreambase and from the
corresponding iostream class.
 These classes are designed to manage the Disk files,
which are declared in fstream and we should include any
program in these files.
 A file stream can be declared using the classes ifstream, ofstream
and fstream that are contained in the Header file fstream.
A file can be Opened into two ways:
Using the Constructor function of the class
Using the Member function open() of the class
OPENING FILES USING Open():
 The function open() can be used to open multiple files that
use the same stream object.
file-stream-class stream-object;
stream-object.open (“file name”);
This condition is necessary for preventing
and read data from the file.
MORE ABOUT OPEN( ): FILE MODES
The function open( ) is used to open a new
and an existing file.
stream-object. open(“file
name”,mode);
Each file has two associated pointers
known as File pointers.
DEFAULT ACTIONS:
When we open a file in read-only-mode
,these input pointer is automatically set
at the beginning.
FUNCTIONS FOR MANIPULATION OF FILE POINTERS:
 seekg()-Moves a pointer to specified location
 seekp()-Moves put pointer to a specified location
 tellg()-Gives the current position of the get pointer
 tellp()-Gives the current position of the put pointer
It supports a number of member function for performing the
input/output operations on files.
Put() and get() Functions:
◦ It is used to handle single character at a time.
◦ The function put() writes a single character to the associated
stream.
◦ The function get() reads a single character to the associated
stream.
Write() and read() Functions:
◦ It is used to read and write the blocks in the binary data.
 It is used to maintain the routine task in the
data file.
 The updation can be done in:
◦ Displaying the contents of a file
◦ Modifying an existing item
◦ Adding a new file
◦ Deleting an existing file
 The reading and writing files may not be true always.
◦ A file which we are attempting to open for reading does not
exist.
◦ The file name used for a new file may already exist.
◦ We may use an invalid file name.
◦ There may not be any space in the disk for storing more data.
◦ We may attempt to perform an operation when the file is not
opened for that purpose.
 This feature facilities the supply of arguments
to the main() function.
 These arguments are supplied at the time of
invoking the program.
◦ C> exam data results
◦ Exam is the name of the file containing the program
to be executed ,data and results are the filenames
passed to the program as command-line arguments.
THANKYOU!!!

More Related Content

What's hot (20)

PDF
File handling
RoshanMaharjan13
 
PPT
intro unix/linux 04
duquoi
 
PPTX
Trace File Database admanistartion and manegment
Kainat Ilyas
 
ODP
intro unix/linux 02
duquoi
 
PPTX
Directory Commands - R.D.Sivakumar
Sivakumar R D .
 
PPT
intro unix/linux 08
duquoi
 
PPTX
How to process csv files
Tukaram Bhagat
 
PPTX
Free Space Management, Efficiency & Performance, Recovery and NFS
United International University
 
PDF
Python - Lecture 11
Ravi Kiran Khareedi
 
PPTX
User and groups administrator
Aisha Talat
 
PPT
intro unix/linux 07
duquoi
 
PPT
MS-DOS
MAQ Institute
 
PPT
OSCh11
Joe Christensen
 
PDF
File Systems
Shipra Swati
 
DOCX
Vb lecture notes
alldesign
 
PDF
Course 102: Lecture 28: Virtual FileSystems
Ahmed El-Arabawy
 
PPT
intro unix/linux 11
duquoi
 
PPTX
File allocation methods (1)
Dr. Jasmine Beulah Gnanadurai
 
DOCX
Set path
Anuj Singh Rajput
 
PDF
help with Linux/Unix starting
dummy
 
File handling
RoshanMaharjan13
 
intro unix/linux 04
duquoi
 
Trace File Database admanistartion and manegment
Kainat Ilyas
 
intro unix/linux 02
duquoi
 
Directory Commands - R.D.Sivakumar
Sivakumar R D .
 
intro unix/linux 08
duquoi
 
How to process csv files
Tukaram Bhagat
 
Free Space Management, Efficiency & Performance, Recovery and NFS
United International University
 
Python - Lecture 11
Ravi Kiran Khareedi
 
User and groups administrator
Aisha Talat
 
intro unix/linux 07
duquoi
 
File Systems
Shipra Swati
 
Vb lecture notes
alldesign
 
Course 102: Lecture 28: Virtual FileSystems
Ahmed El-Arabawy
 
intro unix/linux 11
duquoi
 
File allocation methods (1)
Dr. Jasmine Beulah Gnanadurai
 
help with Linux/Unix starting
dummy
 

Similar to Managing console of I/o operations & working with files (20)

PPTX
Managing,working with files
kirupasuchi1996
 
PPTX
Managing console i/o operation,working with files
ramya marichamy
 
PDF
Basics of files and its functions with example
Sunil Patel
 
PPT
File handling in_c
sanya6900
 
PPT
new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...
AzanMehdi
 
PPT
file_handling_in_c.ppt......................................
nadoj47203
 
PPT
file_handling_in_c.pptbbbbbbbbbbbbbbbbbbbbb
SanskritiGupta39
 
PPT
Filehandlinging cp2
Tanmay Baranwal
 
PPT
File Handling In C++(OOPs))
Papu Kumar
 
PPTX
Stream classes in C++
Shyam Gupta
 
PPTX
Basics of file handling
pinkpreet_kaur
 
PPTX
basics of file handling
pinkpreet_kaur
 
PPTX
File handling.pptx
VishuSaini22
 
PPT
Purdue CS354 Operating Systems 2008
guestd9065
 
PDF
Working with the IFS on System i
Chuck Walker
 
PPTX
Introduction to files management systems
araba8
 
DOC
Project report
meenalpandey
 
PDF
Java IO
UTSAB NEUPANE
 
Managing,working with files
kirupasuchi1996
 
Managing console i/o operation,working with files
ramya marichamy
 
Basics of files and its functions with example
Sunil Patel
 
File handling in_c
sanya6900
 
new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...
AzanMehdi
 
file_handling_in_c.ppt......................................
nadoj47203
 
file_handling_in_c.pptbbbbbbbbbbbbbbbbbbbbb
SanskritiGupta39
 
Filehandlinging cp2
Tanmay Baranwal
 
File Handling In C++(OOPs))
Papu Kumar
 
Stream classes in C++
Shyam Gupta
 
Basics of file handling
pinkpreet_kaur
 
basics of file handling
pinkpreet_kaur
 
File handling.pptx
VishuSaini22
 
Purdue CS354 Operating Systems 2008
guestd9065
 
Working with the IFS on System i
Chuck Walker
 
Introduction to files management systems
araba8
 
Project report
meenalpandey
 
Java IO
UTSAB NEUPANE
 
Ad

More from lalithambiga kamaraj (20)

PPTX
Firewall in Network Security
lalithambiga kamaraj
 
PPTX
Data Compression in Multimedia
lalithambiga kamaraj
 
PPTX
Data CompressionMultimedia
lalithambiga kamaraj
 
PPTX
Digital Audio in Multimedia
lalithambiga kamaraj
 
PPTX
Network Security: Physical security
lalithambiga kamaraj
 
PPTX
Graphs in Data Structure
lalithambiga kamaraj
 
PPTX
Package in Java
lalithambiga kamaraj
 
PPTX
Exception Handling in Java
lalithambiga kamaraj
 
PPTX
Data structure
lalithambiga kamaraj
 
PPTX
Digital Image Processing
lalithambiga kamaraj
 
PPTX
Digital Image Processing
lalithambiga kamaraj
 
PPTX
Estimating Software Maintenance Costs
lalithambiga kamaraj
 
PPTX
Datamining
lalithambiga kamaraj
 
PPTX
Digital Components
lalithambiga kamaraj
 
PPTX
Deadlocks in operating system
lalithambiga kamaraj
 
PPTX
Io management disk scheduling algorithm
lalithambiga kamaraj
 
PPTX
Recovery system
lalithambiga kamaraj
 
PPTX
File management
lalithambiga kamaraj
 
PPTX
Preprocessor
lalithambiga kamaraj
 
PPTX
Inheritance
lalithambiga kamaraj
 
Firewall in Network Security
lalithambiga kamaraj
 
Data Compression in Multimedia
lalithambiga kamaraj
 
Data CompressionMultimedia
lalithambiga kamaraj
 
Digital Audio in Multimedia
lalithambiga kamaraj
 
Network Security: Physical security
lalithambiga kamaraj
 
Graphs in Data Structure
lalithambiga kamaraj
 
Package in Java
lalithambiga kamaraj
 
Exception Handling in Java
lalithambiga kamaraj
 
Data structure
lalithambiga kamaraj
 
Digital Image Processing
lalithambiga kamaraj
 
Digital Image Processing
lalithambiga kamaraj
 
Estimating Software Maintenance Costs
lalithambiga kamaraj
 
Digital Components
lalithambiga kamaraj
 
Deadlocks in operating system
lalithambiga kamaraj
 
Io management disk scheduling algorithm
lalithambiga kamaraj
 
Recovery system
lalithambiga kamaraj
 
File management
lalithambiga kamaraj
 
Preprocessor
lalithambiga kamaraj
 
Ad

Recently uploaded (20)

PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Dimensions of Societal Planning in Commonism
StefanMz
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
community health nursing question paper 2.pdf
Prince kumar
 

Managing console of I/o operations & working with files

  • 3.  The features that supports to format the console I/O operations are: ◦ Ios class functions and flags ◦ Manipulators ◦ User-defined output functions IOS CLASS FUNCTIONS AND FLAGS: It consists of large number of member functions that is used to format the output in number of ways.
  • 4.  MANIPULATORS: These are the special functions that are included in the I/O statements to format the parameters of a stream.  DEFINING FIELD WIDTH: ◦ It is used to define the width of the field. ◦ Can be defined using width(); SETTING PRECISION:  It is used to specify the to be displayed after the decimal point. FILLING AND PADDING:  It is used to print the values using the larger field widths.  It can be declared by, cout.fill();
  • 5. It is used for defining the input and output in various forms. Overloaded Operators >> and <<: • It is used to give the I/O • The >> is overloaded in istream class • The << is overloaded in ostream class Ex: cin>>item1>>item2;
  • 6. put() and get() Functions: ◦ It is used for the input and output . ◦ Put(c) is used to give the input ◦ Get(c) is used to get the output Getline() and write() Functions: • The getline() function reads a whole line of the text and ends with a newline character. • This function can be invoked by, cin.getline (line,size); • The writeline() function reads a whole line of the text and displays an entire line. • This function can be invoked by, cout.write (line,size);
  • 7.  The header file iomanip provides a set of functions called manipulators which can be used to manipulate the output formats.  They provide the same features as that of the ios member function and flag.  Two or more manipulators can be,  Cout<<manip1<<manip1<<manip<<item;  Cout<<manip1<<item1<<manip2<<item2;
  • 8.  The large amount of Data can be handled using some devices such as floppy disk or hard disk to store those datas.  These datas are stored in these devices called FILES.  The Programs can be designed to perform the read and write operations on those files.  Kinds of Data Communication: ◦ Data Transfer between the console unit and the program. ◦ Data Transfer between the program and a Diskfile.
  • 9.  The I/O system contains a set of classes that define the file handling methods.  These includes ifstream, ofstream and fstream.  These classes are derived from fstreambase and from the corresponding iostream class.  These classes are designed to manage the Disk files, which are declared in fstream and we should include any program in these files.
  • 10.  A file stream can be declared using the classes ifstream, ofstream and fstream that are contained in the Header file fstream. A file can be Opened into two ways: Using the Constructor function of the class Using the Member function open() of the class OPENING FILES USING Open():  The function open() can be used to open multiple files that use the same stream object. file-stream-class stream-object; stream-object.open (“file name”);
  • 11. This condition is necessary for preventing and read data from the file. MORE ABOUT OPEN( ): FILE MODES The function open( ) is used to open a new and an existing file. stream-object. open(“file name”,mode);
  • 12. Each file has two associated pointers known as File pointers. DEFAULT ACTIONS: When we open a file in read-only-mode ,these input pointer is automatically set at the beginning. FUNCTIONS FOR MANIPULATION OF FILE POINTERS:  seekg()-Moves a pointer to specified location  seekp()-Moves put pointer to a specified location  tellg()-Gives the current position of the get pointer  tellp()-Gives the current position of the put pointer
  • 13. It supports a number of member function for performing the input/output operations on files. Put() and get() Functions: ◦ It is used to handle single character at a time. ◦ The function put() writes a single character to the associated stream. ◦ The function get() reads a single character to the associated stream. Write() and read() Functions: ◦ It is used to read and write the blocks in the binary data.
  • 14.  It is used to maintain the routine task in the data file.  The updation can be done in: ◦ Displaying the contents of a file ◦ Modifying an existing item ◦ Adding a new file ◦ Deleting an existing file
  • 15.  The reading and writing files may not be true always. ◦ A file which we are attempting to open for reading does not exist. ◦ The file name used for a new file may already exist. ◦ We may use an invalid file name. ◦ There may not be any space in the disk for storing more data. ◦ We may attempt to perform an operation when the file is not opened for that purpose.
  • 16.  This feature facilities the supply of arguments to the main() function.  These arguments are supplied at the time of invoking the program. ◦ C> exam data results ◦ Exam is the name of the file containing the program to be executed ,data and results are the filenames passed to the program as command-line arguments.