Home c++ What does StringStream and not only?

What does StringStream and not only?




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%

  1. StringStream is the same stream , 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 from While) if the user entered the contents of input manually (but the program does not stop waiting for input ). Note that the input variable is used twice: once to initialize StringStream , and then in the cycle reading pieces of this very StringStream . (This is not very beautiful, I would not regret declare a new variable for a new meaning.)
  2. 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.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions