IO_format - Programming Stream Manipulators Prog....

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Programming Stream Manipulators
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Prog. Fundamentals I: Stream Manipulator Slide 2 Stream Manipulators in iostream.h Library I/O stream manipulators modify the behavior of insertions ( << ) and extractions ( >> ). Examples: endl , flush oct , dec , hex (persistent effect: a change stays effective until another change is requested) int i = 10; cout << i << ” ” << i + i << endl; // 10 20 cout << oct << i << ” ” << i + i << endl; // 12 24 cout << hex << i << ” ” << i + i << ” ” << dec << i << endl; // a 14 10 decimal: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 octal: 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20 21 22 23 24 Hexdecimal: 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13 14
Background image of page 2
Number Systems Octal Base 8 8 symbols Hexadecimal Base 16 16 symbols More compact representation of the binary system Decimal Octal Hexadecimal 00 00 0 01 01 1 02 02 2 ... ... ... 07
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/30/2010 for the course COMP COMP102 taught by Professor Lrr during the Fall '09 term at HKUST.

Page1 / 6

IO_format - Programming Stream Manipulators Prog....

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online