C++中的流操纵器的noskipws()方法用于清除指定str流的showbase格式标志。该标志读取第一个非空白字符之前的输入流中的空白。
用法:
ios_base& noskipws (ios_base& str)
参数:此方法接受str作为参数,这是要为其清除格式标志的流。
返回值:此方法返回设置了noskipws格式标志的流str。
范例1:
// C++ code to demonstrate
// the working of noskipws() function
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
// Initializing the character
char a, b, c;
// Stream input with leading whitespaces
istringstream iss(" GFG");
// Using noskipws()
iss >> noskipws >> a >> b >> c;
cout << "noskipws flag:"
<< a << endl
<< b << endl
<< c << endl;
return 0;
}
输出:
noskipws flag:
范例2:
// C++ code to demonstrate
// the working of noskipws() function
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
// Initializing the character
char c;
// Stream input with leading whitespaces
istringstream iss(" G");
// Using noskipws()
iss >> noskipws >> c;
cout << "noskipws flag:"
<< c << endl;
return 0;
}
输出:
noskipws flag:
参考: http://www.cplusplus.com/reference/ios/noskipws/
相关用法
- C++ ios manipulators dec()用法及代码示例
- C++ ios manipulators hex()用法及代码示例
- C++ ios manipulators oct()用法及代码示例
- C++ ios manipulators right()用法及代码示例
- C++ ios manipulators internal()用法及代码示例
- C++ ios manipulators noboolapha()用法及代码示例
- C++ ios manipulators boolalpha()用法及代码示例
- C++ ios manipulators noshowpos()用法及代码示例
- C++ ios manipulators showbase()用法及代码示例
- C++ ios manipulators showpoint()用法及代码示例
- C++ ios manipulators noshowbase()用法及代码示例
- C++ ios manipulators noshowpoint()用法及代码示例
- C++ ios manipulators showpos()用法及代码示例
- C++ ios manipulators skipws()用法及代码示例
- C++ ios manipulators nounitbuf()用法及代码示例
注:本文由纯净天空筛选整理自guptayashgupta53大神的英文原创作品 ios manipulators noskipws() function in C++。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。