What makes the StringStream class?
stringstream SS (INPUT);
While (SS & GT; & GT; INPUT)
According to the program logic, I understand that I enter the SS string, after which the cycle turns on and on the same word it starts to transmit from SS in Input?
Second trouble here.
if (input.front () == input.back ())
{
Size_t Found = Output.find (Input);
If (Found == String :: NPOS)
{
Output.APPEND (INPUT);
output.append (");
}
}
And so checks in the word whether the first and last symbol are equal. Next is incomprehensible. The output line is empty, how can it look in it input input?
In general, you can explain in more detail how everything works here?
Answer 1, Authority 100%
StringStream
is the samestream
, like, for example,cin
, only its contents are taken from the input stream of the program, but from This line line. The effect of your code in principle is the same as fromWhile)
if the user entered the contents ofinput
manually (but the program does not stop waiting for input ). Note that theinput
variable is used twice: once to initializeStringStream
, and then in the cycle reading pieces of this veryStringStream
. (This is not very beautiful, I would not regret declare a new variable for a new meaning.)- It is first the line
Output
empty, and after the first time it will add text. Try to drive a program for such an original line:"One One Ne Two Two"
, you will immediately become clearer.