here is my code
It takes whole line of string(including spaces) as argument and break the string at each space(as done in python by split() operator). now you can do what you want with each individual string. This comes in rescue when we don’t know what the number of string to take as input.So we simply take as a line and by using stringstream we break it. You can use this technique in this problem.
String stream is useful to read the spaces in between the words and also it is use full to compare to copy to cancatarate and to find the string length