std::skipws
Defined in header <ios> | | |
|---|---|---|
std::ios_base& skipws( std::ios_base& str ); | (1) | |
std::ios_base& noskipws( std::ios_base& str ); | (2) | |
启用或禁用默认为%29启用的格式化输入函数%28跳过前导空格。对输出没有影响。
1%29启用skipws溪流中的旗子str好像通过打电话str.setf(std::ios_base::skipws)...
2%29禁用skipws溪流中的旗子str好像通过打电话str.unsetf(std::ios_base::skipws)...
的构造函数执行空格跳过。std::basic_istream::sentry,它读取并丢弃按std::ctype流%27s注入区域设置的方面。
这是一个I/O操作程序,可以用表达式调用它,如out << std::noskipws对任何out类型std::basic_ostream或使用表达式,如in >> std::noskipws对任何in类型std::basic_istream...
参数
str | - | reference to I/O stream |
|---|
返回值
str%28操作后对流的引用%29。
例
二次
#include <iostream>
#include <sstream>
int main()
{
char c1, c2, c3;
std::istringstream("a b c") >> c1 >> c2 >> c3;
std::cout << "Default behavior: c1 = " << c1 << " c2 = " << c2 << " c3 = " << c3 << '\n';
std::istringstream("a b c") >> std::noskipws >> c1 >> c2 >> c3;
std::cout << "noskipws behavior: c1 = " << c1 << " c2 = " << c2 << " c3 = " << c3 << '\n';
}二次
产出:
二次
Default behavior: c1 = a c2 = b c3 = c
noskipws behavior: c1 = a c2 = c3 = b二次
另见
resetiosflags | clears the specified ios_base flags (function) |
|---|---|
setiosflags | sets the specified ios_base flags (function) |
© cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

