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.