I'm having trouble with file reading/formatting ...
I am given a file songs.txt which contains data on each line in the following format
A KISS TO BUILD A DREAM ON___ARMSTRONG, LOUIS___MAG6037___BEST LOVED BALLADS CD+G
In my main file I have:
and in my songs.cpp file I have overloaded the >> operator like so:
vector<Song> Info; //vector object info takes in a Song object
Song input; //object created whose information will be parsed
while(filename >> input) //calls overloaded >> operator
//read while data exists to be read
Info.push_back(input);//appends the string to the vector
and I have also overloaded the << operator like so:
istream& operator>> (istream &is, Song &song)
getline(is, song.title, '_');
is >> lastname >> ws >> firstname;
is >> song.album;
song.artist = lastname + firstname;
ostream& operator<< (ostream &os, Song &song)
os << setw(30) << left << song.title << ':'
<< song.artist << ':'
<< setw(20) << left << song.album;
I want to be able to store the song's title, artist, and album.
Technically I don't need the 7 character ID num but for now I'm just including it as part of the album name.
I just used the ':' so that I know when each variable (title, artist, album) ends
My concern is that I'm not able to store the artist name correctly
For example it turns out like this:
A KISS TO BUILD A DREAM ON:_ARMSTRONG,LOUIS___MAG6037___BEST:LOVED BALLADS CD+G
I want to ignore the dash right after the artists first name so that its not included in song.artist.