I would like to parse a sentence beginning with a number:
2 random sentece.
5 another one.
8 this is really long sentence.
Into int number
holding the beginning number and the rest in std::string sentence
. So in the first line, the parsing output will be number == 2
and sentence == "random sentence"
. The input is read from stdin, but the classical std::cin >> number >> sentence
does'n work, since the parsing of string would end once it reaches a space. But I want to make the string beginning after the initial number to the end of line \n
. So, how to do it in C++?
![how to parse line into number and string? [closed]](https://file.115kc.com/storage/eg/image37.jpg)