bml wrote:[color=blue]
>[color=green][color=darkred]
> > > 2. Sub-string of an "istringstream"
> > >
> > > string str1, str2, str3, str4;
> > > ist >> str1 ;
> > > ist >> str2 ;
> > > ist >> str3;
> > > ist >> str4;
> > >
> > > How to insert the sub-string, "test", directly into str4, without going
> > > through str1, str2, and str3?[/color]
> >
> > There is no way. It's a stream. Well, not entirely true, you could
> > of course, position the sream if you knew where.
> >[/color]
>
> What do you mean by positioning the stream?[/color]
How old are you? I don't ask because I want to be impolite
or I want to insult you BUT I just want to know if you are old
enough to remember the days of audio casette recorders or tape
drives.
A stream works like a tape. You can only read and write sequentially.
Well. If you know exactly what you are looking for you can press the[color=blue][color=green]
>> button on your tape deck and do a fast forward. But you need to[/color][/color]
be carefull, without a tape meter it is practically impossible to
position the tape *exactly* where you want to start. And even then it
is impossible if you don't know the length of each song on the tape.
With a stream its similar: If you know the exact location you can
position the stream there and start reading. But without this knowledge
you are lost. So if there are 4 words in the stream and you do not know
anything about them such as the length of each, there simply is no way to
determine the start of the 4-th word other then read through the previous
words.
--
Karl Heinz Buchegger
kbuchegg@gascad.at