How can I go about detecting a space OR another specific character/symbol in one line of a file using the fstream library?
For example, the text file would look like this:
Dog Rover
Cat Whiskers
Pig Snort
I need the first word to go into one variable, and the second word to go into another separate variable. This should happen for every line in the text file.
Any suggestions?
This is pretty simple.
If that’s not quite what you want, please elaborate your question.
Perhaps a better way overall is to use a vector of strings…
This will give you a vector
vthat holds all the words in your file.