This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
istringstream extraction
- To: "'libstdc++ at sourceware dot cygnus dot com'" <libstdc++ at sourceware dot cygnus dot com>
- Subject: istringstream extraction
- From: Jim Parsons <parsons at clearway dot com>
- Date: Mon, 24 Jan 2000 17:41:57 -0500
Hello,
We have detected what we think may be an anomoly in the
way integers are extracted from the istringstream class. Below please
find short sample code and the results. It seems as if the stream
pointer doesn't advance after attempting to extract an integer value.
When we check with the .good operation, the result shows a bad
extraction. Also, when we replace .get with .getline delimited on '(',
and using is >> c has the same effect.
Any thoughts on this problem would be very greatly appreciated. Is
this correct operation? Can we help pin this down/fix this if necessary?
-Jim Parsons
#include <iostream>
#include <string>
#include <sstream>
void main(void)
{
unsigned int h4, h3, h2;
char c;
string s("Parse numbers (205,199,144)");
istringstream is(s);
do {
c = is.get();
cout <<"c is "<<c<<endl;
} while ( (c != EOF) && (c != '('));
if(c == EOF)
cout << "Couldn't find parens" << endl;
is >> h4;
is >> c;
if(c != ',')
{
cout << "Couldn't find comma!" << endl;
cout << "h4 is " << h4 << endl;
cout << "c is " << c << endl;
}
else
cout << "All well" << endl;
}
c is P
c is a
c is r
c is s
c is e
c is
c is n
c is u
c is m
c is b
c is e
c is r
c is s
c is
c is (
Couldn't find comma!
h4 is 205199144
c is )
------------------------------------------------------------------