Javatpoint Logo
Javatpoint Logo

C++ Manipulator setfill

C++ manipulator setfill() function is used to specify a different character to fill the unused filed width of the value.

This manipulator is declared in header <iomanip>.

Syntax

Parameter

c: The new fill character for the stream.

Char_type is the type of the characters used by the stream.

Return value

This function returns an object of unspecified type. The setbase function should only be used as a stream manipulator.

Data Races

The stream object on which it is inserted or extracted is modified and concurrent access to the same stream object may introduce data races.

Exceptions

Object is in a valid state, if any exception is thrown.

Example 1

Let's see the simple example to demonstrate the use of setfill:

Output:

xxxxxxxx24

Example 2

Let's see another simple example:

Output:

default fill:         42
setfill('*'): ********42

Example 3

Let's see another simple example:

Output:

**200**300
***200***300
****200****300
*****200*****300
Next TopicC++ Manipulator





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA