ios manipulators unitbuf() function in C++ Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The unitbuf() method of stream manipulators in C++ is used to set the unitbuf format flag for the specified str stream. This flag flushes the associated buffer after each operation. Syntax: ios_base& unitbuf (ios_base& str) Parameters: This method accepts str as a parameter which is the stream for which the format flag is affected. Return Value: This method returns the stream str with unitbuf format flag set. Example 1: CPP // C++ code to demonstrate // the working of unitbuf() 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 unitbuf() // buffer flushed 3 times iss >> unitbuf >> a >> b >> c; cout << "unitbuf flag: " << a << endl << b << endl << c << endl; return 0; } Output: unitbuf flag: G F G Example 2: CPP // C++ code to demonstrate // the working of unitbuf() 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 unitbuf() // buffer flushed 5 times iss >> unitbuf >> a >> b >> c >> d >> e; cout << "unitbuf flag: " << a << endl << b << endl << c << endl << d << endl << e << endl; return 0; } Output: unitbuf flag: G E E K S Reference: https://cplusplus.com/reference/ios/unitbuf/ Comment More infoAdvertise with us Next Article ios manipulators right() function in C++ G guptayashgupta53 Follow Improve Article Tags : Misc C++ cpp-ios cpp-manipulators Practice Tags : CPPMisc Similar Reads ios manipulators nounitbuf() function in C++ The nounitbuf() method of stream manipulators in C++ is used to clear the showbase format flag for the specified str stream. This flag does not flushes the associated buffer after each operation. Syntax: ios_base& nounitbuf (ios_base& str) Parameters: This method accepts str as a parameter w 2 min read ios manipulators nounitbuf() function in C++ The nounitbuf() method of stream manipulators in C++ is used to clear the showbase format flag for the specified str stream. This flag does not flushes the associated buffer after each operation. Syntax: ios_base& nounitbuf (ios_base& str) Parameters: This method accepts str as a parameter w 2 min read ios manipulators right() function in C++ The right() method of stream manipulators in C++ is used to set the adjustfield format flag for the specified str stream. This flag sets the adjustfield to right. It means that the number in the output will be padded to the field width by inserting fill characters at the start. Syntax: ios_base& 1 min read ios manipulators right() function in C++ The right() method of stream manipulators in C++ is used to set the adjustfield format flag for the specified str stream. This flag sets the adjustfield to right. It means that the number in the output will be padded to the field width by inserting fill characters at the start. Syntax: ios_base& 1 min read ios manipulators oct() function in C++ The oct() method of stream manipulators in C++ is used to set the baseline format flag for the specified str stream. This flag sets the baseline for Octal numbers. Hence the output shows the number in Octal base. Syntax: ios_base& oct (ios_base& str) Parameters: This method accepts str as a 1 min read ios manipulators oct() function in C++ The oct() method of stream manipulators in C++ is used to set the baseline format flag for the specified str stream. This flag sets the baseline for Octal numbers. Hence the output shows the number in Octal base. Syntax: ios_base& oct (ios_base& str) Parameters: This method accepts str as a 1 min read Like