RE: [Dev-C++] read numeric data in C++
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <Mat...@Ve...> - 2005-03-10 23:43:13
|
For some reason this doesn't seem quite right, guys.
If you are trying to empty a stringstream object so you can fill it wil
new/different stuff just call ss.str("").
If you are trying to sync it up and write it out just call ss.flush().
HTH,
Matt
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]On Behalf Of Alfred P.
Reaud
Sent: Thursday, March 10, 2005 3:30 PM
To: Dev-Cpp UserList
Subject: Re: [Dev-C++] read numeric data in C++
That's interesting. The symptom makes it look like istr or i is only being
set once. It's hard to tell without looking at it with a debugger....
Doesn't the clear method actually deallocate the string (not the pointer
that is implied in the string object). And is it calling string::clear,
ios_base::clear, or both? The actual machine line call label
was:_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate. I didn't
trace into that function. I'm using Insight BTW, using Mixed view.
Possibly it's not flushing the string buffer buffer, which may be implied in
the clear method? I didn't go into any of the routines with the debugger,
but at the machine level, the only difference is the commented out line. I
didn't look to see if it was in the << or >> of istr, though the problem is
in it's functionality somewhere.
Jeremy Hill <jer...@co...> wrote:
<snip>
while (fin >> holder)
{
istr << holder;
istr >> i;
cout << holder << "/" << i << endl;
istr.clear(); //stringstreams suck, you have to do
//this to get it to work properly.
}
};
<snip>
Incidently, anyone want to take a crack at why I have to clear the
string of the stringstream for it to work properly? If I don't, I get
this:
10/10
20/10
30/10
40/10
50/10
60/10
70/10
80/10
90/10
100/10
-- Jeremy
<snip>
Alfred P. Reaud <mailto:al...@ya...>
<http://www.geocities.com/alreaud/>
___________________________________________________________________
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure. If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof. Thank you.
|