This is a function I created for creating a course folder inside a section folder which already exists. However, when I run this function my console app just crashes. I need help trouble shooting.
The first part is simply an authentication for a correctly entered degree program. The course ID has a validation of four integers on it. I omitted that part of the code since it was error free.
In the next part I retrieve a name of sections from a file containing their name "Sectionlist.csv" and pass it on to strings to create directories and then create quizzes and assignments.csv files. However, this crashes the console app exactly after the message "Course has been successfully created".
Here is my code for that last part. What could be the possible reasons here? Any help will be appreciated.
string sectiondir="./data/"+program_entered+"/Sectionlist.csv";//directory of section list
string secname[3];//array for sections
ifstream sectionlist(sectiondir.c_str()); // reading section file of the degree programme
int iterator=0;
if (sectionlist.fail())
cerr << "File couldnt be opened" << endl;
else
while (!(sectionlist.eof())) { // reading name of sections and storing in section array
getline(sectionlist,secname[iterator],'\n');
iterator++;
}
for (int i=0;i<iterator;i++) { // loop for running the section array
string newdir="./data/" +program_entered + "/" + secname[i] + "/" + course_entered; // directory for new course in each section
_mkdir(newdir.c_str()); // make directory function
string quizdir = newdir + "/quizes.csv"; // directory for resective quizes
string assigndir = newdir + "/assignments.csv"; // directory for respective assignments
ofstream quizes(quizdir.c_str(),ios::app); // creating a file of quizes.csv
ofstream assignments(assigndir.c_str(),ios::app); // creating an assignment file
}