home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!think.com!paperboy.osf.org!hsdndev!cfa203!cfa.harvard.edu!murison
- From: murison@cfa.harvard.edu (Marc A. Murison)
- Newsgroups: comp.lang.c++
- Subject: Re: buffering iostreams
- Summary: casting destroys buffering -- but not in BC++ 3.1
- Message-ID: <murison.64.0@cfa.harvard.edu>
- Date: 28 Jan 93 13:19:19 GMT
- References: <1k2co6INN7mm@wilma.cs.widener.edu>
- Sender: news@head-cfa.harvard.edu
- Organization: Smithsonian Astrophysical Observatory
- Lines: 33
-
- /*In article <1k2co6INN7mm@wilma.cs.widener.edu> quairoli@cs.widener.edu (
- Patrick J. Quairoli) writes:
- >[...]
- >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 '.
- >[...]
- >? how do i get a long to be cast as a char and still buffer it?
- >(i'm using BC++ 3.0)
-
- Using BC++ 3.1, the following produces 'H ...':
- */
-
- #include <iomanip.h>
- void main( void )
- {
- long foo = 72;
- cout << setiosflags( ios::left )
- << setw(sizeof(long))
- << (char)foo << "...";
- }
-
- /*
- Leave out the left justification, and it produces ' H...'.
- Perhaps there was a change from BC++ 3.0 to 3.1?
- */
- ---------------------------------------------------------------------
- | Marc A. Murison | Smithsonian Astrophysical Observatory |
- | murison@cfa.harvard.edu | 60 Garden Street, MS 63 |
- | (617) 495-7079 | Cambridge, MA 02138 |
- ---------------------------------------------------------------------
-