How do you write a program that reads a text file (music.txt) & stores it in a Data Structure.
I am a novice learning over the internet so I this is something I have never done.
How do I do this?
I hope that I explained this well but here is a little more info incase not
Write a program that reads the data from the
music.txt file and store it in a data structure. To implement this data structure you must use an array of songs and each song must be represented by a struct with appropriate fields.
Any advice on how to do this would be extremely helpful :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <fstream>
#include <strstream>
usingnamespace std;
int main()
{
ifstream fin("music.txt");
if (fin.fail()) {
cout << "Can't open file!\n";
}
Start creating the data structure for the songs ( the members depend on the information you need to store ), after that you can overload the >> operator to read data from the file stream to your structure