Read from file help

So I have to read from a file, and store the information in separate variables. My problem is that for some of the information I need multiple words, and for others I don't, so I cant simply store 1 word into a variable and store the next in another in so on. To demonstrate what I mean let me give an example.

Dog Cat Blue Bird Snake White Horse

I am able to store "Dog","Cat","Blue","Bird"...etc in variables but I don't know how to make it so I can store "Dog" in one variable, "Cat" in a second variable. and "Blue Bird" in a third variable. "Snake" would be the 4th and "White Horse" would be the fifth. How can I read a file and manipulate the pointer to grab what I need?
Thanks in advance for the help!
I do not know if you have learned this yet, but try using the vector library.
Get the word from the text file (as a string) and push it back into the vector. Keep track of how many words you have put into the vector.
http://www.cplusplus.com/reference/vector/vector/

Unless the words are separated by line breaks or a special character, there is no way to tell the program to determine if a variable will be two words long or one (it cannot tell if "Blue" and "Bird" are separate variables or part of a two-word variable).
you could use getline(myfile,string,':'); repeated again and again...
Topic archived. No new replies allowed.