Selecting words from files?

I want to know a way to select specific words not characters in a text file. Example

file
"the cat ran away"

how would I be able to select the 3rd word which would be "ran".

and also, how could I remove "ran" so the input file can be like this

"the cat away"

thanks for the help.
I'm not a pro but it seems the problem your describing sounds like it can be broken down into 3 steps:

1) Read the contents of the file into a string.
-More info can be found here: http://www.cplusplus.com/doc/tutorial/files/

2) Tokenize the string (retrieved from the input file) into an array.
-Tokenizing the string can separate the text into words, if the set the delimiter to ' ' (space)
-You could store the individual words in a string array.
-Be aware that this is a C function.
-More info here: http://www.cplusplus.com/reference/clibrary/cstring/strtok/

3) Write the tokenized string to file (omitting which ever words you want).

Hope this helps.
The proper solution would be to use boost::string::split or an equivalent function.
http://www.boost.org/doc/libs/1_46_1/doc/html/string_algo/usage.html#id2728530
Topic archived. No new replies allowed.