Stream.cpp
TCP1, p. 105-106
download
#include <iostream>
using std::cout;
using std::endl; // newline
using std::dec; // decimal (base 10)
using std::oct; // octal (base 8)
using std::hex; // hexadecimal (base 16)
int main()
{
// Specifying formats with manipulators:
cout << "A number in decimal: "
<< dec << 15 << '\n';
cout << "in octal: " << oct << 15 << "\n";
cout << "in hex: " << hex << 15 << endl;
cout << "A floating-point number: "
<< 3.14159 << char(10); // newline (ASCII 10)
cout << "non-printing char (escape): "
<< char(27) << char(10); // newline
}
/*
g++ Stream.cpp -o Stream
./Stream
A number in decimal: 15
in octal: 17
in hex: f
A floating-point number: 3.14159
non-printing char (escape):
*/
Comments
Post a Comment