C++ examples for File Stream:cout
Using stream manipulators hex, oct, dec and setbase for Integral Stream Base: dec, oct, hex and setbase
#include <iomanip> #include <iostream> int main(int argc, const char *argv[]) { int number = 100; // use hex stream manipulator to show octal number std::cout << number << " in hexadecimal is: " << std::hex << number << std::endl;//from w w w .j a va 2s.co m // use oct stream manipulator to show decimal in number std::cout << std::dec << number << " in octal is: " << std::oct << number << std::endl; // use setbase stream manipulator to show decimal number std::cout << std::setbase(10) << number << " in decimal is: " << number << std::endl; return 0; }