This is my struct:
struct Event{
int day;
int month;
int year;
int weekday;
string event;
};
My events data file would be like this:
# Comment and empty lines are ignored
# ’$’ means LAST, ’*’ is wildcard
# Weekday on symbolic from Mon,Tue,Wed,Thu,Fri,Sat,Sun
# Events specs start
# Last day is payday
$.*.*:*:Payday
# Birthday at 1.3
1.3.*:*:Birthday Party
# Darts on Fridays
*.*.*:Fri:Darts evening
13.*.*:Fri:Friday the 13th
# EOF
I tried to write this function:
void readFile(vector<string> &data){
string line;
ifstream readFile("events.dat", ios::in);
if (!readFile) {
cerr<<"File COuld not be opened"<<endl;
exit(EXIT_FAILURE);
}
while (readFile && !readFile.eof()) {
getline(readFile,line);
if (line.length() == 0 or line[0] == '#' or line[0] == '/')
break;
data.push_back(line);
}
}
But now I don't know how to convert data vector to event vector?