noskipws
描述 (Description)
它用于清除str流的skipws格式标志。 当未设置skipws格式标志时,流上的所有操作都将初始空白字符视为要提取的有效内容。
声明 (Declaration)
以下是std :: noskipws函数的声明。
ios_base& noskipws (ios_base& str);
参数 (Parameters)
str - 格式标志受影响的Stream对象。
返回值 (Return Value)
它返回Argument str。
异常 (Exceptions)
Basic guarantee - 如果抛出异常,str处于有效状态。
数据竞争 (Data races)
它修改了str。 对同一流对象的并发访问可能会导致数据争用。
例子 (Example)
在下面的例子中解释了std :: noskipws函数。
#include <iostream>
#include <sstream>
int main () {
char a, b, c;
std::istringstream iss (" 123");
iss >> std::skipws >> a >> b >> c;
std::cout << a << b << c << '\n';
iss.seekg(0);
iss >> std::noskipws >> a >> b >> c;
std::cout << a << b << c << '\n';
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 -
123
1