/facepalm
Ok, so I have to make a program upon startup it has to read from a said file which looks something like this
Song Name
Artist
Genre
Track Time
That is one block of the array, their is a max of 10.
Ive been googling and searching the forums for help but nothing hit the nail on the head, or better yet my head.
If I can this function started I can possibly be well on my way to finishing.
Here is what I got so far...All I am doing is reading the data from the file and printing it out so see if it reads correctly
#include <iostream>
#include <fstream>
using namespace std;
const int MAX_SONGS = 10;
int main()
{
ifstream fin;
int i =0, count = 0;
struct music_list{
string title, artist, genre;
int track_time;
};
music_list songs[MAX_SONGS];
fin.open("song.dat");
getline(fin,songs[i].title);
getline(fin,songs[i].artist);
getline(fin,songs[i].genre);
fin>>songs[i].track_time;
while(fin.eof() && count<MAX_SONGS){
getline(fin,songs[i].title);
getline(fin,songs[i].artist);
getline(fin,songs[i].genre);
fin>>songs[i].track_time;
count++;
}
for(i=0; i<=count; i++){
cout<<songs[i].title
<<songs[i].artist
<<songs[i].genre
<<songs[i].track_time;
}
fin.close();
system("PAUSE");
return 0;
}
I am sure there is a more efficient way of coding this simple function, I am just over thinking it.