Hi :)

How do you write a program that reads a text file (music.txt) & stores it in a Data Structure.

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.

So far all I have is this(very simple I know) but so far is it correct?

Any advice on how to do this would be extremely helpful :)

#include <iostream>
#include <fstream>
#include <strstream>

using namespace std;

int main()
{
	ifstream fin("music.txt");


	if (fin.fail()) {
		cout << "Can't open file!\n";
	}

The first thing you have to do is design the structure. What information is on each line of the file? You can't do anything else until you figure that out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.