< Prev
Next >



C++ formatted I/O functions




Formatted console input/output functions are used for performing input/output operations at console and the resulting data is formatted and transformed.

Some of the most important formatted console input/output functions 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 input stream, without removing it from the stream.

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

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

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



In C++, we can read the input entered by a user at console using an object cin of istream class and we can write the output at console using an object cout of ostream class. Through the cin and cout objects, we can access the formatted I/O functions.




Please subscribe our social media channels for notifications, we post a new article everyday.

Decodejava Google+ Page Decodejava Facebook Page  DecodeJava Twitter Page

Coming Next
-
Python

Ad2