I'm trying to explode a string and put each word in a vector. I don't know how to use stringstream yet, and I'm trying to get practice at using some of the member functions of string. I can get the first word in the right position, but then I can't figure out why I get the 2nd word plus the first 3 chars of the 3rd word in the 2nd position. Any help is appreciated.
wow, thanks for pointing out that mistake. I thought the two arguments were a range, I'll try and correct it! Wish there was a member function that allowed one to specify a range.
Here is my new code that works for everything but the last word of the string, because there is no space after the last word in the string. I know I could do it by searching for a period the same way I search for a space for the last word, and that would always work as long as there was a period, but I thought I'd ask if anyone else has other suggestions for this situation. Am I going about this the right way? thanks.
Thanks LowestOne, I just implemented your suggestion and it works like a charm.
I've read about string::npos but I don't have the greatest understanding of it. I guess as long as I know how to use it, thats the most important thing. So far I just know it can be used as a parameter to mean the end of a string. If someone has a better understanding and cares to explain, I know I will benefit from it.
Thanks again cpp community, you've really helped me out!