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:

C++ help fix my dynamic array program #include #include #include #include #include

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!