📜  C++中的ios操纵器nounitbuf()函数

📅  最后修改于: 2021-05-30 08:45:52             🧑  作者: Mango

C++中的流操纵器nounitbuf()方法用于清除指定str流的showbase格式标志。每次操作后,此标志不会刷新关联的缓冲区。

句法:

ios_base& nounitbuf (ios_base& str)

参数:此方法接受str作为参数,这是要为其清除格式标志的流。

返回值:该方法返回设置了nounitbuf格式标志的流str。

范例1:

// C++ code to demonstrate
// the working of nounitbuf() function
  
#include 
#include 
  
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 
#include 
  
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++基础课程为基础,以先进的C++和C++ STL课程基础加上STL。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程”