[kde-edu]: Reading int from a string
Andreas Nicolai
Andreas.Nicolai at gmx.net
Wed May 4 03:46:50 CEST 2005
Hi there,
I ask that question first in my "home" mailing list and I'm pretty sure one of
you knows a good solution to this problem.
I have a string containing statistics data, multiple triples of integers. For
instance:
"120 2 32 123 38 77 8392 32 3"
So far I've read string like that using pure C++:
----
std::stringstream strm(data);
int a, b, c;
while (strm >> a >> b >> c) {
// store a, b and c
}
----
When I try the same with the QT Textstreams the last triple is never read:
----
QTextStream strm(data, IO_ReadOnly);
int a, b, c;
while (strm >> a >> b >> c) {
// store a, b and c
}
----
The problem is that after reading the last triple the stream is no longer
"good" (it has the state atEnd()) even though the last triple was
successfully read. All trials to read the state from the IO_device have
failed so far. Does anyone know how to solve this problem?
Bye,
Andreas
More information about the kde-edu
mailing list