home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK4 / SAMPLES / IOSTUTOR / EXIOS203.CP$ / EXIOS203
Encoding:
Text File  |  1991-11-25  |  578 b   |  35 lines

  1. // exios203.cpp
  2. // 2-argument manipulator example
  3. #include <iostream.h>
  4. #include <iomanip.h>
  5.  
  6. struct fillpair {
  7.        char ch;
  8.        int  cch;
  9. };
  10.  
  11. IOMANIPdeclare( fillpair );
  12.  
  13. ostream& fp( ostream& os, fillpair pair )
  14. {
  15.     for ( int c = 0; c < pair.cch; c++ ) {
  16.         os << pair.ch;
  17.     }
  18.     return os;
  19. }
  20.  
  21. OMANIP(fillpair) fill( char ch, int cch )
  22. {
  23.     fillpair pair;
  24.  
  25.     pair.cch = cch;
  26.     pair.ch  = ch;
  27.     return OMANIP (fillpair)( fp, pair );
  28. }
  29.  
  30.  
  31. void main()
  32. {
  33.     cout << "10 dots coming" << fill( '.', 10 ) << "done" << endl;
  34. }
  35.