Stream Input/Output

               ios
               / \
              /   \
         istream  ostream
           / \     / \
          /   \   /   \
   ifstream  iostream  ofstream   			
                |
                |
             fstream

Iostream Library

  1. <iomanip.h>
  2. <fstream.h>
  3. <strstream.h>
  4. <stdiostream.h>

Stream Output

Stream Extraction >>

Stream Manipulators


                                Parameter
Header File     Function        Type          Effect
--------------------------------------------------------------------------------------------
iostream.h      endl            None        Terminate the current output line
iomanip.h       setw(n)         int         Sets field width to n
iomanip.h       setprecision(n) int         Set floating point precision to n digits
--------------------------------------------------------------------------------------------
Stream formatting funcions

Stream Format States

      ios::skipws

      ios::left
      ios::right
      ios::internal

      ios::dec
      ios::oct
      ios::hex
	  
      ios::showbase
      ios::showpoint
      ios::uppercase
      ios::showpos
	  
      ios::scientific
      ios::fixed

Stream Input

Stream Insertion <<

Get and Getline Member Functions

Streams and Files

Examples

  1. lines.cc (use getline)
  2. lines2.cc (use get)
  3. wcount2.cc
  4. wcount.cc (use string stream)
  5. readnums.cc

Stream member funcions