input spacing

I'm writing a program that organizes music. My problem is skipping white space with the input.

For example;

Artist Song
Johnny Cash Big River
The Temptations Get Ready
System Of A Down Toxicity


Currently, my program has
Artist = Johnny
Song = Cash

when I really want
Artist = Johnny Cash
Song = Big River

I want one variable to contain the entire artist name and one for the song name. How do I go about doing this when there is so much white space to be skipped? How do I make the program know when the artist ends and where the song begins?

Sorry if this is unclear but any help is appreciated.
Thanks.
That is going to be tough since some artist names contain two words, some 3, some 5, and so forth. Do you see the problem with that?

Try adding a delimiter to the text file such as a ':' between fields. If you are going to work with text files you must define a file format where the program can recognize where one field ends and another begins.

Johnny Cash: Big River, Ring of Fire
System of a Down: Toxicity

You see where I am going with that? If you read each line into a std::string using getline, then the program can parse each string by searching for the known delimiter that signifies where the artist name ends. In my example, I also showed how you can setup multiple songs per artist using commas.
That's a great idea! Thanks.
Common delimited file types in the industry are CSV (comma separated values, where strings are quoted but numbers are not), pipe-delimited, and tab-delimited. Tabs are nice for this sort of thing because it is unlikely that a song or band name will have a tab in it.
Topic archived. No new replies allowed.