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

  1. Path: sparky!uunet!cimshop!davidm
  2. From: davidm@consilium.com (David S. Masterson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: buffering iostreams
  5. Message-ID: <DAVIDM.93Jan26105053@consilium.com>
  6. Date: 26 Jan 93 18:50:53 GMT
  7. References: <1k2co6INN7mm@wilma.cs.widener.edu>
  8. Sender: root@cimshop.UUCP
  9. Distribution: comp
  10. Organization: Consilium Inc., Mountain View, California
  11. Lines: 36
  12. In-reply-to: quairoli@cs.widener.edu's message of 26 Jan 93 03:55:50 GMT
  13. X-Posting-Software: GNUS 3.13  [ NNTP-based News Reader for GNU Emacs ]
  14.  
  15. >>>>> On 26 Jan 93 03:55:50 GMT, quairoli@cs.widener.edu (Patrick J. Quairoli)
  16. >>>>> said:
  17.  
  18. > i'm trying to take a long (i.e. 72) and cast it as a char so
  19. > that i get a value of 'H'.  this can be easily done by:
  20.  
  21. > long foo = 72;
  22. > cout << (char)foo;
  23.  
  24. > BUT!  i also want the output to be buffered as an long (4 bytes).
  25.  
  26. [...deleted...]
  27.  
  28. What you are discussing is not referred to as "buffering".  Buffering is what
  29. occurs when characters that you write to a stream are not immediately written
  30. to the output location, but rather are held in internal memory until a
  31. sufficient number have been "buffered" to be efficiently written out.
  32.  
  33. What you are looking for is output format control -- the process of making
  34. your output look the way you want it to.  Doing this depends on exactly what
  35. you're doing, but the easiest is:
  36.  
  37. cout << (char) foo << "   ";
  38.  
  39. All of the special format control mechanisms (like setw) that I see in
  40. iostreams are used for controlling the appearance of numeric values (of which
  41. foo casted to char is not).  For character string output, you have to do it by
  42. hand (but you could hide that in a manipulator).
  43.  
  44. --
  45. ====================================================================
  46. David Masterson                    Consilium, Inc.
  47. (415) 691-6311                    640 Clyde Ct.
  48. davidm@consilium.com                Mtn. View, CA  94043
  49. ====================================================================
  50.     "Boldy going where no one has gone before."
  51.