What is wrong with this code?
Suppose
1.
tempString
contains the following:"/454/665/4/"
2.
i
is always the position of the first integer after "/"
3.
tempBuf
points to the
stringbuf
of
tempStream
4.
tempVar
is
int
1 2 3 4 5
|
tempBuf->str(tempString.substr(i,tempString.find('/',i)-i));
cout<<tempBuf->str();
tempStream.flush();
tempStream>>tempVar;
cout<<tempVar;
|
I put this in a loop(if necessary, I'll put the rest of the code here also), and every time it should have different result(the next string of numbers should be assigned to tempVar), but it doesn't. I expect this:
454 454 665 665 4 4
(without the space, I put it for clearness)
but I get this instead:
454 454 665 454 4 454
So what is wrong with the code? Or maybe I am expecting something wrong...
Thanks in advance, and also, I have posted this in another thread, but didn't get an answer(although got answers for lots of other things, thanks shacktar, but I am in haste). Peace \/