Javatpoint Logo
Javatpoint Logo

C++ Manipulator ws

C++ manipulator ws function is used to discard leading whitespace from an input stream.

This function extracts as many whitespace characters as possible from the current position in the input sequence. This extraction stops as soon as a non-whitespace character is found. These extracted whitespace characters are discarded.

Syntax

Parameter

is: Input stream object from where whitespace are extracted.

Return value

It returns argument is.

Data Races

Modifies the stream object is.

If we try to concurrent access to the same stream object then it may cause data races, except for the standard stream objects cin and wcin when these are synchronized with stdio.

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 istream ws:

Output:

java, Tpoint

Example 2

Let's see another simple example:

Output:

ws + getline returns: "JavaTPoint tutorial"

Example 3

Let's see another simple example:

Output:

         Hello!!
Please, enter some whitespaces followed by a sentence:
      Myself Nikita kesharwani
Please, enter some whitespaces followed by a sentence:

You wrote:
Hello!!
Myself Nikita Kesharwani
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