home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!hela.iti.org!cs.widener.edu!widener!nobody
- From: quairoli@cs.widener.edu (Patrick J. Quairoli)
- Newsgroups: comp.lang.c++
- Subject: buffering iostreams
- Date: 25 Jan 1993 22:55:50 -0500
- Organization: Widener University CS Department, Chester PA
- Lines: 33
- Sender: quairoli@cs.widener.edu
- Distribution: world
- Message-ID: <1k2co6INN7mm@wilma.cs.widener.edu>
- NNTP-Posting-Host: wilma.cs.widener.edu
- Summary: casting destroys buffering
-
- i'm trying to take a long (i.e. 72) and cast it as a char so
- that i get a value of 'H'. this can be easily done by:
-
- long foo = 72;
-
- cout << (char)foo;
-
- BUT! i also want the output to be buffered as an long (4 bytes).
-
- i've tried:
-
- cout << setw(sizeof(long)) << (char)foo;
-
- which gives me 'H' but it is not buffered (i.e. its' flush with the
- left of the screen and there are no trialing spaces). if it were
- buffered as a long it would be 'H '.
-
- if i use:
-
- cout << setw(sizeof(long)) << foo;
-
- i get 72 and it is buffered with 2 leading spaces (i.e. two bytes)....
-
- ? how do i get a long to be cast as a char and still buffer it?
-
- (i'm using BC++ 3.0)
-
- e-mail replies please.
- --
- _____________________________________________________________________________
- patrick quairoli quairoli@cs.widener.edu department of
- rebel coordinator widener university computing services
- "Time is a Spiral - Space is a Curve" - Rush
-