home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cimshop!davidm
- From: davidm@consilium.com (David S. Masterson)
- Newsgroups: comp.lang.c++
- Subject: Re: buffering iostreams
- Message-ID: <DAVIDM.93Jan26105053@consilium.com>
- Date: 26 Jan 93 18:50:53 GMT
- References: <1k2co6INN7mm@wilma.cs.widener.edu>
- Sender: root@cimshop.UUCP
- Distribution: comp
- Organization: Consilium Inc., Mountain View, California
- Lines: 36
- In-reply-to: quairoli@cs.widener.edu's message of 26 Jan 93 03:55:50 GMT
- X-Posting-Software: GNUS 3.13 [ NNTP-based News Reader for GNU Emacs ]
-
- >>>>> On 26 Jan 93 03:55:50 GMT, quairoli@cs.widener.edu (Patrick J. Quairoli)
- >>>>> said:
-
- > 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).
-
- [...deleted...]
-
- What you are discussing is not referred to as "buffering". Buffering is what
- occurs when characters that you write to a stream are not immediately written
- to the output location, but rather are held in internal memory until a
- sufficient number have been "buffered" to be efficiently written out.
-
- What you are looking for is output format control -- the process of making
- your output look the way you want it to. Doing this depends on exactly what
- you're doing, but the easiest is:
-
- cout << (char) foo << " ";
-
- All of the special format control mechanisms (like setw) that I see in
- iostreams are used for controlling the appearance of numeric values (of which
- foo casted to char is not). For character string output, you have to do it by
- hand (but you could hide that in a manipulator).
-
- --
- ====================================================================
- David Masterson Consilium, Inc.
- (415) 691-6311 640 Clyde Ct.
- davidm@consilium.com Mtn. View, CA 94043
- ====================================================================
- "Boldy going where no one has gone before."
-