Specifying formats with manipulators, number formatting in decimal, octal, and hexadecimal. - C++ File Stream

C++ examples for File Stream:cout

Description

Specifying formats with manipulators, number formatting in decimal, octal, and hexadecimal.

Demo Code

#include <iostream>
using namespace std;
int main() {//from ww w .j a v  a  2s .  c  o  m
   cout << "a number in decimal: "  << dec << 15 << endl;
   cout << "in octal: " << oct << 15 << endl;
   cout << "in hex: " << hex << 15 << endl;
   cout << "a floating-point number: "  << 3.14159 << endl;
   cout << "non-printing char (escape): "  << char(27) << endl;
}

Result


Related Tutorials