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