okay i'm working on a very complicated problem (for me anyway) and i know i'm missing something somewhere. i need to be able to store data into an array but i don't want it looping right off. this is the structure for the data i need and my function headers. i need to read the struct into the addCourse functions but the only way i know to make an array work is to loop for all the data at once. however, thats not what i want to do. i want to be able to add one course then go back to the menu and add another if i chose then output the schedule.
struct courseInfo
{
string courseName;
string crn;
int startTime;
int endTime;
string days;
};
//function prototypes
void displayMenu (int choice);
void addCourse (courseInfo addList[]);
void displaySchedule (courseInfo addList[]);
//declare constant
const int LIMIT = 20;
here's the addCourse function. i warn you its messy.
void addCourse (courseInfo addList[])
{
int i=0;
cout << "Enter the course title:" << endl;
cin >> addList[i].courseName;
cout << "Enter the course CRN:" << endl;
cin >> addList[i].crn;
cout << "Enter the start time for this course:" << endl;
cin >> addList[i].startTime;
cout << "Enter the end time for this course:" << endl;
cin >> addList[i].endTime;
cout << "Enter the days of the week the course occurs on:" << endl;
cin >> addList[i].days;
return;
}
i've tried a couple variations on loops and such but i just can't seem to make it work right. what i need to be able to do is the menu will show and the user choses the add course option, i need to store that info for recall later by other functions. how do i do that without looping the function itself? i want the option of the menu in between each entry without losing the data. thanks in advance! i hope i wasn't too confusing. if so just ask and i can try to clarify.