Question
C++ help fix my dynamic array program #include #include #include #include #include using namespace std; struct Classes { string names; //Holds names of the students
C++ help fix my dynamic array program
#include#include #include #include #include using namespace std; struct Classes { string names; //Holds names of the students string *courses; //Number of students int num; //Holds the courses the student is taking }; int main(int argc, const char * argv[]) { fstream fin; fin.open ("courses.txt"); int size; //Number of students fin >> size; Classes * a = new Classes[size]; //Array of struct which holds a students name and classes char el; fin.get(el); for (int ct = 0; ct > a[ct].num; a[ct].courses = new string [a[ct].num]; //Array that holds a student courses for ( int ct2=0; ct2 > a[ct].courses[ct2]; } fin.get(el); } cout > choice; while (choice != 'Q') { if (choice == 'D') { cout > courses; cout > choice; } system("pause"); }
courses.txt looks like this:
12
John Milligan
3 CIS100 CIS105 MAT113
Jill Kerning
5 CIS100 CIS105 MAT232 BIO100 ENG101
Aaron Spencer
4 CIS201 CIS225 MAT232 ENG101
Damon Hill
2 CIS334 CIS400
Kaitlyn Stamen
4 CIS100 CIS10 MAT113 BIO100
Debbie Martin
5 CIS100 CIS105 MAT232 CHY112 ENG101
Greg Nolan
2 CIS334 CIS450
Lynn Sanders
4 CIS334 CIS450 MAT250 BIO100
Alicia Thomas
4 CIS226 CIS450 MAT232 CHY112
Alan Turner
5 CIS100 CIS105 MAT232 BIO100 ENG101
Paul Henley
5 CIS100 CIS105 CIS334 ENG101 MAT232
Tim Copeland
1 CIS450
End result should look like this:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started