iomanip setbase() function in C++ with Examples Last Updated : 30 May, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The setbase() method of iomanip library in C++ is used to set the ios library basefield flag based on the argument specified as the parameter to this method. Syntax: setbase (int base) Parameters: This method accepts base as a parameter which is the integer argument corresponding to which the base is to be set. 10 stands for dec, 16 stands for hex, 8 stands for oct, and any other value stands for 0 (reset). Return Value: This method does not returns anything. It only acts as stream manipulators. Example 1: CPP // C++ code to demonstrate // the working of setbase() function #include <iomanip> #include <ios> #include <iostream> using namespace std; int main() { // Initializing the integer int num = 50; cout << "Before set: \n" << num << endl; // Using setbase() cout << "Setting base to hex" << " using setbase: \n" << setbase(16) << num << endl; return 0; } Output:Before set: 50 Setting base to hex using setbase: 32 Example 2: CPP // C++ code to demonstrate // the working of setbase() function #include <iomanip> #include <ios> #include <iostream> using namespace std; int main() { // Initializing the integer int num = 50; cout << "Before set: \n" << num << endl; // Using setbase() cout << "Setting base to oct" << " using setbase: \n" << setbase(8) << num << endl; return 0; } Output:Before set: 50 Setting base to oct using setbase: 62 Reference: http://www.cplusplus.com/reference/iomanip/setbase/ Comment More infoAdvertise with us Next Article ios setstate() function in C++ with Examples G guptayashgupta53 Follow Improve Article Tags : C++ cpp-input-output CPP-Functions Practice Tags : CPP Similar Reads iomanip setfill() function in C++ with Examples The setfill() method of iomanip library in C++ is used to set the ios library fill character based on the character specified as the parameter to this method. Syntax: setfill(char c) Parameters: This method accepts c as a parameter which is the character argument corresponding to which the fill is t 2 min read iomanip setiosflags() function in C++ with Examples The setiosflags() method of iomanip 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 metho 1 min read iomanip resetiosflags() function in C++ with Examples The resetiosflags() method of iomanip library in C++ is used to reset the ios library format flags specified as the parameter to this method.Syntax: resetiosflags (ios_base::format_flag) Parameters: This method accepts format_flag as a parameter which is the ios library format flag to be reset by th 2 min read iomanip setprecision() function in C++ with Examples The setprecision() method of iomanip library in C++ is used to set the ios library floating point precision based on the precision specified as the parameter to this method. Syntax: setprecision(int n) Parameters: This method accepts n as a parameter which is the integer argument corresponding to wh 2 min read ios setstate() function in C++ with Examples The setstate() method of ios class in C++ is used to change the current state of this stream by setting the flags passed as the parameters. Hence this function changes the internal state of this stream. Syntax: void setstate(iostate state) Parameters: This method accepts the iostate as parameter whi 2 min read setw() function in C++ with Examples The setw() method of iomanip library in C++ is used to set the ios library field width based on the width specified as the parameter to this method. The setw() stands for set width and it works for both the input and the output streams.Syntaxsetw(int n);Parameters:n: It is the integer argument corre 2 min read Like