The () method of iomaip library in C++ is used to set the ios library format flags specified as the parameter to this method.
Syntax:
setiosflags (ios_base::format_flag)
Parameters: This method accepts format_flag as a parameter which is the ios library format flag to be set by this method.
Return Value: This method does not returns anything. It only acts as stream manipulators.
Example 1:
// C++ code to demonstrate // the working of setiosflags() function #include <iomanip> #include <ios> #include <iostream> using namespace std; int main() { // Initializing the integer int num = 50; // Using setiosflags() cout << "Setting showbase flag " << "using setiosflags: \n" << hex << setiosflags(ios::showbase) << num << endl; return 0; } |
Setting showbase flag using setiosflags: 0x32
Example 2:
// C++ code to demonstrate // the working of setiosflags() function #include <iomanip> #include <ios> #include <iostream> using namespace std; int main() { // Initializing the integer int num = 50; // Using setiosflags() cout << "Setting showbase and uppercase" << " flag using setiosflags: \n" << hex << setiosflags( ios::showbase | ios::uppercase) << num << endl; return 0; } |
Setting showbase and uppercase flag using setiosflags: 0X32
Reference: http://www.cplusplus.com/reference/iomanip/setiosflags/
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- iomanip setpricision() function in C++ with Examples
- iomanip setw() function in C++ with Examples
- iomanip resetiosflags() function in C++ with Examples
- iomanip setbase() function in C++ with Examples
- iomanip setfill() function in C++ with Examples
- ios eof() function in C++ with Examples
- ios bad() function in C++ with Examples
- log2() function in C++ with Examples
- fill_n() function in C++ STL with examples
- wcsspn() function in C/C++ with Examples
- wcslen() function in C++ with Examples
- fill() function in C++ STL with examples
- ios operator() function in C++ with Examples
- norm() function in C++ with Examples
- ios operator() function in C++11 with Examples
- quick_exit() function in C++ with Examples
- ios fail() function in C++ with Examples
- ios rdstate() function in C++ with Examples
- ios setstate() function in C++ with Examples
- ios good() function in C++ with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

