Advertisement



< Prev
Next >



C++ Formatted I/O Functions




In C++, the formatted console input/output functions are used for performing input/output operations at the console by formatting the data in a particular format.

Some of the most important formatted console input/output functions in C++ are -

Functions Description
width(int width)
Using this function, we can specify the width of a value to be displayed in the output at the console.

fill(char ch)
Using this function, we can fill the unused white spaces in a value(to be printed at the console), with a character of our choice.

setf(arg1, arg2)
Using this function, we can set the flags, which allow us to display a value in a particular format.

peek()
The function returns the next character from the input stream, without removing it from the stream.

ignore(int num)
The function skips over a number of characters, when taking an input from a user at the console.

putback(char ch)
This function appends a character(which was last read by the get() function), back to the input stream.

precision(int num_of_digts)
Using this function, we can specify the number of digits to the right of a decimal in a floating-point value to be printed in the output.



In C++, we can read the input entered by a user at the console by using the cin object of the istream class, and we can write the output at the console by using the cout object of the ostream class.

Note: Through the cin and cout objects, we can access the formatted I/O functions.




Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement