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++。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。