iomanip - STL C++

setbase()

Declaration

(unspecified) setbase(int iBase);

Description

This is the setbase() function for output stream manipulation. The argument iBase sets the number base that is used for numerical integer output.

Header Include

#include <iomanip>

Example

#include <iostream>
#include <iomanip>

int main() {
	using namespace std;

	int iInt = 1234;
	// Output the value with the default decimal setting
	cout << "Default: " << iInt << endl;

	// Output the value in hexadecimal
	cout << setbase(16);
	cout << "Hexadecimal: " << iInt << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

setbase() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.