1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
int play_radio(string numero)
{
std::srand ( unsigned ( std::time(0) ) );
Musica person;
vector<Musica> music = vector<Musica>();
//vector<Musica> music;
ifstream dataFile("musica.txt");
string _iD, _title, _artist, _author, _album, _genre, _year = "";
string line;
getline(dataFile, line);
const char comma = ',';
while (getline(dataFile, line))
{
istringstream ss(line);
if(!line.empty())
{
//cout << "passei por aqui" << endl;
//userList = splitUserString(line);
//parse(line,",",userList);
getline(ss, _iD, comma);
person.setID(_iD);
getline(ss, _title, comma);
person.setTitle(_title);
getline(ss, _artist, comma);
person.setArtist(_artist);
getline(ss, _author, comma);
person.setAuthor(_author);
getline(ss, _album, comma);
person.setAlbum(_album);
getline(ss, _genre, comma);
person.setGenre(_genre);
getline(ss, _year, comma);
person.setYear(_year);
music.push_back(person);
}
}
dataFile.close();
// set some values:
//for (int i=1; i<10; ++i) myvector.push_back(i); // 1 2 3 4 5 6 7 8 9
// using built-in random generator:
random_shuffle( music.begin(), music.end() );
std::cout << "myvector contains:";
for (vector<int>::iterator it=music.begin(); it!=music.end(); it++)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
|