Okay so let's say i have a string passed on to me: a = "hello;theyarearbitrary;lengths; " i want just the words before ';'. i know i can use getline, but it would only get the first word and won't go through the rest, how would i get the rest of the words: theyarearbitrary;lengths; "?
I'm not sure what lang you are using, but there should be something called a "delimeter" in your case ';' is the delimeter.
I'm using c++. I know i can use getline(string, 100, ';') but wouldn't that just get "hello" What if i wanted to also get "theyarearbitrary" and "lengths"?
Doesn't getline just get the first thing before the delimeter then ignore the rest?
oic there are 3 words,. sorry.... you can go through the delimeter multiple times.
How would you do that though? do you have to create a loop for getline?
not too sure how it works in C++, it should all be on the same line....
Actually, you'd probably be better off using a scanner type class to tokenize the input string and then concatenate it back as you want.
oh yeah I forgot about tokenizers :). I saw the word once and checked it out briefly.... I don't do much with strings and stuff.... My dad loves them, but I don't use them much....
Would it possible if one of you were to examplin it to me? i searched for it but i am lost.
http://www.cplusplus.com/reference/cstring/strtok/ I thought the STL had a token class, guess not.
Join our real-time social learning platform and learn together with your friends!