VOOZH about

URL: https://www.geeksforgeeks.org/cpp/iomanip-setbase-function-in-c-with-examples/

⇱ iomanip setbase() function in C++ with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

iomanip setbase() function in C++ with Examples

Last Updated : 12 Jul, 2025

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: 

Output:
Before set: 
50
Setting base to hex using setbase: 
32

Example 2: 

Output:
Before set: 
50
Setting base to oct using setbase: 
62

Reference: https://cplusplus.com/reference/iomanip/setbase/

Comment
Article Tags: