Article View: comp.std.c++
Article #3687istrstreams and width
From: Tim Ottinger
Date: Fri, 15 Mar 1996 15:06
Date: Fri, 15 Mar 1996 15:06
41 lines
2476 bytes
2476 bytes
We've already worked around this (identified two way to do so) but we
wonder why it doesn't work this way:
Given:
istrstream source;
int i;
string s;
source >> setw(2) >> i >> s;
With fixed length fields (yes, we have to read mainframe data from time to
time, and a few other odd sources), sometimes the fields are butted up against
each other, and sometimes the strings have initial digit characters i them.
When the stream contains "01115 N Neil", it would be nice if "01" and "115 N
Neil" were broken out, but every compiler we try pulls "01115" as the number,
and "N Neil" is the string.
Of course, if we insert whitespace or use read, this works. And we should use
read() because we're doing fixed length, but I was wondering why setw()
doesn't apply to integer extractors.
Surely a lot of people have to read fixed-length records, and this is a common
thing.
Any thoughts?
Tim
******************************************************************************
* Tim Ottinger, Sr Tech tottinge@csci.csc.com *
* CSC Communications Industry Services 217-351-8508x2420 *
* TRIS Division -- Cellular Billing and Support Fax 217-351-2640 *
******************************************************************************
* Requirements have always been the least stable part of any project I have *
* worked upon. -- Robert Martin via Usenet 12/02/95 *
******************************************************************************
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Technical Details
Message-ID:
<4ibvn8$4gr@venus.roc.csci.csc.com>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backShow Full Headers
Complete Article Headers
From: tottinge@csci.csc.com (Tim Ottinger) Message-ID: <4ibvn8$4gr@venus.roc.csci.csc.com> X-Original-Date: Fri, 15 Mar 96 13:48:15 GMT Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back Date: 15 Mar 96 15:06:25 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Subject: istrstreams and width Organization: CSC CIS - TRIS DIVISION X-Newsreader: News Xpress Version 1.0 Beta #3 X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMUmHjOEDnX0m9pzZAQFitgF+KjIHWV8r6/PxMUsHHkPOTNJHLf7OdUyZ Gj7zBxNWNZ++zQmjyoNBZvdK2TgTx2nu =HTMK