#include <iostream>
#include <string>
#include <sstream>
int main()
{
std::istringstream stm( "track1|song1|artist1|album1|\n"
"track2|song2|artist2|album2|\n"
"track3|song3|artist3|album3|\n"
"track4|song4|artist4|album4|\n" ) ;
std::string track ;
std::string song ;
std::string artist ;
std::string album ;
constexpr char delimiter = '|' ;
while( std::getline( stm, track, delimiter) &&
std::getline( stm, song, delimiter) &&
std::getline( stm, artist, delimiter) &&
std::getline( stm, album, delimiter) &&
stm.ignore( 1000, '\n' ) )
{
std::cout << "track: " << track << "\nsong: " << song
<< "\nartist: " << artist << "\nalbum: " << album << "\n\n" ;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c3N0cmVhbT4KCmludCBtYWluKCkKewogICAgc3RkOjppc3RyaW5nc3RyZWFtIHN0bSggInRyYWNrMXxzb25nMXxhcnRpc3QxfGFsYnVtMXxcbiIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAidHJhY2syfHNvbmcyfGFydGlzdDJ8YWxidW0yfFxuIgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICJ0cmFjazN8c29uZzN8YXJ0aXN0M3xhbGJ1bTN8XG4iCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInRyYWNrNHxzb25nNHxhcnRpc3Q0fGFsYnVtNHxcbiIgKSA7CgogICAgc3RkOjpzdHJpbmcgdHJhY2sgOwogICAgc3RkOjpzdHJpbmcgc29uZyA7CiAgICBzdGQ6OnN0cmluZyBhcnRpc3QgOwogICAgc3RkOjpzdHJpbmcgYWxidW0gOwogICAgY29uc3RleHByIGNoYXIgZGVsaW1pdGVyID0gJ3wnIDsKCiAgICB3aGlsZSggc3RkOjpnZXRsaW5lKCBzdG0sIHRyYWNrLCBkZWxpbWl0ZXIpICYmCiAgICAgICAgICAgIHN0ZDo6Z2V0bGluZSggc3RtLCBzb25nLCBkZWxpbWl0ZXIpICYmCiAgICAgICAgICAgIHN0ZDo6Z2V0bGluZS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