pdeopura
May 28th, 2008, 09:24 PM
With the following code, I'm trying to read a .txt file line by line.
I want to read through the file until the last line.... Is my if statement correct in saying that if getline(is, line) exists? Will it skip every other line? If incorrect, what's a way to do it? Thanks in advance!
istream& operator>> (istream &is, const Song &song) // reads in the values of song
{
if ( getline(is, line) )
{
Song *currentSong = new Song(NULL, NULL, NULL);
getline(inf, currentSong->titleID, "___");
getline(inf, currentSong->artistID, "___");
inf.ignore(11, "___");
getline(inf, currentSong->albumID);
return is;
}
}
I want to read through the file until the last line.... Is my if statement correct in saying that if getline(is, line) exists? Will it skip every other line? If incorrect, what's a way to do it? Thanks in advance!
istream& operator>> (istream &is, const Song &song) // reads in the values of song
{
if ( getline(is, line) )
{
Song *currentSong = new Song(NULL, NULL, NULL);
getline(inf, currentSong->titleID, "___");
getline(inf, currentSong->artistID, "___");
inf.ignore(11, "___");
getline(inf, currentSong->albumID);
return is;
}
}