home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 20079 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.6 KB  |  46 lines

  1. Path: sparky!uunet!think.com!paperboy.osf.org!hsdndev!cfa203!cfa.harvard.edu!murison
  2. From: murison@cfa.harvard.edu (Marc A. Murison)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: buffering iostreams
  5. Summary: casting destroys buffering -- but not in BC++ 3.1
  6. Message-ID: <murison.64.0@cfa.harvard.edu>
  7. Date: 28 Jan 93 13:19:19 GMT
  8. References: <1k2co6INN7mm@wilma.cs.widener.edu>
  9. Sender: news@head-cfa.harvard.edu
  10. Organization: Smithsonian Astrophysical Observatory
  11. Lines: 33
  12.  
  13. /*In article <1k2co6INN7mm@wilma.cs.widener.edu> quairoli@cs.widener.edu (
  14. Patrick J. Quairoli) writes:
  15. >[...]
  16. >i've tried:
  17. >cout << setw(sizeof(long)) << (char)foo;
  18. >which gives me 'H' but it is not buffered (i.e. its' flush with the
  19. >left of the screen and there are no trialing spaces). if it were
  20. >buffered as a long it would be 'H   '.
  21. >[...]
  22. >? how do i get a long to be cast as a char and still buffer it?
  23. >(i'm using BC++ 3.0)
  24.  
  25. Using BC++ 3.1, the following produces 'H   ...':
  26. */
  27.  
  28. #include <iomanip.h>
  29. void main( void )
  30. {
  31.     long foo = 72;
  32.     cout << setiosflags( ios::left ) 
  33.          << setw(sizeof(long)) 
  34.          << (char)foo << "...";
  35. }
  36.  
  37. /*
  38. Leave out the left justification, and it produces '   H...'.
  39. Perhaps there was a change from BC++ 3.0 to 3.1?
  40. */
  41. ---------------------------------------------------------------------
  42. | Marc A. Murison          |  Smithsonian Astrophysical Observatory |
  43. | murison@cfa.harvard.edu  |  60 Garden Street,  MS 63              |
  44. | (617) 495-7079           |  Cambridge, MA 02138                   |
  45. ---------------------------------------------------------------------
  46.