A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_skipws.htm below:

C++ ios::Skipws() Function

C++ ios::Skipws() Function

The C++ std::ios::skipws() function is a manipulator used with the input streams. When it is invoked on the input stream, it makes the stream to skip any whitespace characters (spaces, tabs, newlines) before extracting the actual input. This ensures that whitespace does not interfere with reading data from the stream.

Syntax

Following is the syntax for std::ios::skipws() function.

ios_base& skipws (ios_base& str);
Parameters Return Value

This function returns the Argument str.

Exceptions

If an exception is thrown, str is in a valid state.

Data races

It modifies str. Concurrent access to the same stream object may cause data races.

Example

In the following example, we are going to consider the basic usage of the skipws() function.

#include <iostream>
#include <sstream>
int main()
{
    std::istringstream x("  1  12");
    int a, b;
    x >> std::skipws >> a >> b;
    std::cout << "a: " << a << ", b: " << b << std::endl;
    return 0;
}
Output

Output of the above code is as follows −

a: 1, b: 12
Example

Consider the following example, where we are going to disable the skipws() function.

#include <iostream>
#include <sstream>
int main()
{
    std::istringstream a("  1  22");
    int x, y;
    a >> std::noskipws >> x >> y;
    std::cout << "x : " << x << ", y : " << y << std::endl;
    return 0;
}
Output

Following is the output of the above code −

x : 0, y : 32761

ios.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4