does anyone know the function that will take an array of text and cut it up into words and also cout different words;
ex. I prompt the user to input some text and the i send that text to a function that couts each different word on a new line
does anyone know the function that will take an array of text and cut it up into words and also cout different words;
ex. I prompt the user to input some text and the i send that text to a function that couts each different word on a new line
Where does the computer get the pair of scissors from into order to cut up the words?
No, on a serious note you probably want to look at the function:
Code:cin.getline
and consider how do count white spaces since it is these which divides sentences into words.
Then output the words onto separate lines
1. Declare a string variable.Originally Posted by hopeolicious
2. Prompt user to enter a sentence.
3. Call getline to stuff sentence into the string variable.
4. Initialize an istringstream variable with the string input by user.
5. Call the STL copy function to read from the istringstream variable and write to cout with a newline seperator after each word.
That's it, 5 lines of code. Enjoy!
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
You COULD use a vector array of word and "puchback" tehm into the array, then map them out. That is how I believe chatterbots do it, and it allows for wordlist[i] to be used and all that.
This war, like the next war, is a war to end war.