I writing a program for school that needs to keep a calender of when assignments are due. I need to keep the course name (e.g. cs162), a description of the homework and a due date into an array of structs with a struct for the date within the first struct.
struct dueDate{
int mm[2];
int dd[2];
int yyyy[4];
};
struct Task{
char course[MAX_CAP];
char description[MAX_CHAR];
dueDate dueDate;
};
The first thing I need to do is read in any assignments that may already exist in from an already created file. The format of the file is this:
courseName; description; mm/dd/yyyy (dueDate).
Here is the load function (problem is after the strcpy's trying to get the int into the dueDate struct):
void loadDB(Task assignment[], int& size, char location[]){
ifstream inTasks;
char courseName[MAX_CAP];
char fullDescription[MAX_CHAR];
int mm;
int dd;
int yyyy;
Task courseAssignment;
cout << "inside" << endl;
inTasks.open(location);
while(!inTasks){
cerr << "There is a problem with the path of the file " << location << "!";
exit(1);
}
inTasks.get(courseName, MAX_CAP, ';');
while(!inTasks.eof()){
inTasks.ignore(MAX_CAP, ';');
inTasks.get(fullDescription, MAX_CHAR, ';');
inTasks.ignore(MAX_CHAR, ';');
inTasks >> mm;
inTasks.ignore(MAX_CAP, '/');
inTasks >> dd;
inTasks.ignore(MAX_CAP, '/');
inTasks >> yyyy;
inTasks.ignore(MAX_CAP, '\n');
strcpy(courseAssignment.course, courseName);
strcpy(courseAssignment.description, fullDescription);
// PROBLEM
// the warings are under the courseAssignment part
// the error message is "expression must be a modifiable lvalue"
courseAssignment.dueDate.mm = mm;
courseAssignment.dueDate.dd = dd;
courseAssignment.dueDate.yyyy = yyyy;
addToDB(assignment, size, courseAssignment);
inTasks.get(courseName, MAX_CAP, ';');
}
}
Thank you.