Hi, I'm new to the C++ community hope you guys can give me some guidance.
The program I'm making is suppose to read information from a file called music.txt
Inside this file there is information about songs in the following format:
Bandname, Songname, Duration of the Song,
Here a partial extract of the file:
AC/DC,Dirty Deeds Done Dirt Cheap,303,
Alison Moyet,All Cried Out,410,
Allan Browne Quintet,Cyclosporin,291,
The Angels,Take A Long Line,180,
Architecture In Helsinki,Maybe You Can Owe Me,242,
The code I've come up with so far should suggest that there is:
1. An array of 62 songs.
2. Struct for each song to organize all 3 pieces of information.
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
struct songType
{
string bandName;
string songName;
int duration;
};
songType songs[62];
int main()
{
ifstream infile;
infile.open ("music.txt");
string line;
for (int counter = 0; counter < 62; counter++)
{
infile >> songs[counter].bandName = getline(infile, line, ',');
infile >> songs[counter].songName = getline(infile, line, ',');
infile >> songs[counter].duration = getline(infile, line, ',');
}
return 0;
}
Here is the problem, I get the following error:
Description Resource Path Location Type
C:/Users/Shuda/Desktop/C++/Eclipse/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ios_base.h `std::ios_base& std::ios_base::operator=(const std::ios_base&)' is private Test 784 C/C++ Problem within this context.
This appears at:
infile >> songs[counter].bandName = getline(infile, line, ',');
Does anyone have any suggestions about what I'm doing wrong?