C++中的流操縱器的skipws()方法用於為指定的str流設置skipws格式標誌。該標誌在第一個非空白字符之前跳過輸入流中的空白。
用法:
ios_base& skipws (ios_base& str)
參數:此方法接受str作為參數,這是格式標誌受影響的流。
返回值:此方法返回設置了skipws格式標誌的流str。
範例1:
// C++ code to demonstrate
// the working of skipws() 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 skipws()
iss >> skipws >> a >> b >> c;
cout << "skipws flag:"
<< a << endl
<< b << endl
<< c << endl;
return 0;
}
輸出:
skipws flag:G F G
範例2:
// C++ code to demonstrate
// the working of skipws() function
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
// Initializing the character
char a;
// Stream input with leading whitespaces
istringstream iss(" G");
// Using skipws()
iss >> skipws >> a;
cout << "skipws flag:"
<< a << endl;
return 0;
}
輸出:
skipws flag:G
參考: http://www.cplusplus.com/reference/ios/skipws/
相關用法
- C++ ios manipulators oct()用法及代碼示例
- C++ ios manipulators right()用法及代碼示例
- C++ ios manipulators dec()用法及代碼示例
- C++ ios manipulators hex()用法及代碼示例
- C++ ios manipulators showbase()用法及代碼示例
- C++ ios manipulators noshowbase()用法及代碼示例
- C++ ios manipulators fixed()用法及代碼示例
- C++ ios manipulators left()用法及代碼示例
- C++ ios manipulators noshowpos()用法及代碼示例
- C++ ios manipulators noskipws()用法及代碼示例
- C++ ios manipulators boolalpha()用法及代碼示例
- C++ ios manipulators nounitbuf()用法及代碼示例
- C++ ios manipulators internal()用法及代碼示例
- C++ ios manipulators showpos()用法及代碼示例
- C++ ios manipulators noshowpoint()用法及代碼示例
注:本文由純淨天空篩選整理自guptayashgupta53大神的英文原創作品 ios manipulators skipws() function in C++。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。