![]() |
Copying one vector to another
I've been working on a program that is meant to take a full sentence from the user (saved as a vector<char>) and divide it into words. It does this by using an iterator in a for loop that looks something like this:
Code:
for ( *iter = sentence.begin(); *iter != ' '; iter++ )I need a way to fill in the line of code commented in the above block. The eventual outcome of the program is supposed to be the computer displaying each separate word in the sentence, so you can see that I need a way to put each word into a vector of its own. Then I can iterate through it and display each word. My other problem is, how can I fill a vector<char> up with a string from the user? For example, if the user input: Code:
Hello world.Code:
H, e, l, l, o, , w, o, r, l, d, .I hope this makes sense; if not, I'll be happy to try to clarify. Thanks. |
| All times are GMT +5.5. The time now is 11:26. |