home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_11 / 1011051b < prev    next >
Text File  |  1992-09-08  |  572b  |  41 lines

  1.  
  2.  
  3. ********************************************************
  4.  
  5. // VSTREAM.CPP (Listing 6)
  6. // Video stream package -- Williams
  7. #include <iostream.h>
  8. #include <conio.h>
  9.  
  10.  
  11. class Conbuf : public streambuf
  12. {
  13. int do_sputn(const char *s,int n);
  14. int overflow(int=EOF);
  15. } conbuf;
  16.  
  17. int Conbuf::overflow(int c)
  18. {
  19. do_sputn((char *)&c,1);
  20. return 1;
  21. }
  22.  
  23. int Conbuf::do_sputn(const char *s,int n)
  24. {
  25. int n1=n;
  26. while (n1--)
  27.         {
  28.         putch(*s);
  29.         if (*s++=='\n')
  30.           {
  31.           putch('\r');
  32.           clreol();
  33.           }
  34.         }
  35. return n;
  36. }
  37.  
  38. ostream conout=&conbuf;
  39.  
  40.  
  41.