home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!agate!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!niwot.scd.ucar.edu!cruff
- From: cruff@niwot.scd.ucar.edu (Craig Ruff)
- Newsgroups: gnu.g++.lib.bug
- Subject: Possible output field adjustment bug
- Date: 26 Jan 1993 22:17:14 -0500
- Organization: GNUs Not Usenet
- Lines: 39
- Sender: daemon@cis.ohio-state.edu
- Approved: bug-lib-g++@prep.ai.mit.edu
- Distribution: gnu
- Message-ID: <9301261812.AA00515@maroon.scd.ucar.edu>
-
- I have found a possible bug in the field adjustment operators of the stream
- class. The following program:
-
- #include <iostream.h>
-
- main()
- {
- cout.width(4);
- cout << '(' << -12 << ")\n";
-
- cout.width(4);
- cout.setf(ios::left, ios::adjustfield);
- cout << '(' << -12 << ")\n";
-
- cout.width(4);
- cout.setf(ios::internal, ios::adjustfield);
- cout << '(' << -12 << ")\n";
- }
-
- Produces:
- (-12)
- ( -12)
- (-12)
-
- According to page 343 of Stroustrup's "The C++ Programming Language", 2nd
- edition it should produce:
- ( -12)
- (-12 )
- (- 12)
-
- The width function should apply to the next numeric or string output
- operation, not to characters. Now, to me, it would seem that symmetric
- operation of the field adjustments are desirable. Is this the intent
- of the libg++ versions?
- Craig Ruff NCAR cruff@ncar.ucar.edu
- (303) 497-1211 P.O. Box 3000
- Boulder, CO 80307
-
-
-