home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19899 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  1.4 KB

  1. Path: sparky!uunet!hela.iti.org!cs.widener.edu!widener!nobody
  2. From: quairoli@cs.widener.edu (Patrick J. Quairoli)
  3. Newsgroups: comp.lang.c++
  4. Subject: buffering iostreams
  5. Date: 25 Jan 1993 22:55:50 -0500
  6. Organization: Widener University CS Department, Chester PA
  7. Lines: 33
  8. Sender: quairoli@cs.widener.edu
  9. Distribution: world
  10. Message-ID: <1k2co6INN7mm@wilma.cs.widener.edu>
  11. NNTP-Posting-Host: wilma.cs.widener.edu
  12. Summary: casting destroys buffering
  13.  
  14. i'm trying to take a long (i.e. 72) and cast it as a char so
  15. that i get a value of 'H'.  this can be easily done by:
  16.  
  17. long foo = 72;
  18.  
  19. cout << (char)foo;
  20.  
  21. BUT!  i also want the output to be buffered as an long (4 bytes).
  22.  
  23. i've tried:
  24.  
  25. cout << setw(sizeof(long)) << (char)foo;
  26.  
  27. which gives me 'H' but it is not buffered (i.e. its' flush with the
  28. left of the screen and there are no trialing spaces). if it were
  29. buffered as a long it would be 'H   '.
  30.  
  31. if i use:
  32.  
  33. cout << setw(sizeof(long)) << foo;
  34.  
  35. i get 72 and it is buffered with 2 leading spaces (i.e. two bytes)....
  36.  
  37. ? how do i get a long to be cast as a char and still buffer it?
  38.  
  39. (i'm using BC++ 3.0)
  40.  
  41. e-mail replies please.
  42. -- 
  43. _____________________________________________________________________________
  44. patrick quairoli           quairoli@cs.widener.edu        department of
  45. rebel coordinator        widener university           computing services
  46. "Time is a Spiral - Space is a Curve" - Rush 
  47.