Hello,
We were tasked with creating a program that tracks textbooks. For an example, if I entered in terminal this: B 1234567890123 Books Title
Then the output would have store the book, and output "Book is defined"
B character is for defining a book, Now C character defines a course, so if I entered: C CSEE 212 Programming Class
It would output, "course is created".
Now in my code, the switch case for "C" seem to throw an arrow in execution mode, like "aborted...out of range" But it takes my case B, M, A, correctly. Can anyone point me to finding my error?
The code is lengthy so posted the switch case portion only.
Code:int main() { string code; istringstream iss(line); iss>>code; long newISBN = 0; int bookIndex = 0; char updateCode; switch(code.at(0)) { case 'B': books[bookCounter] = new Book; iss>>books[bookCounter]->isbn; books[bookCounter]->title = iss.str().substr(iss.tellg()); bookCounter++; break; case 'C': course[courseCounter] = new Course; //Help in here. iss>>course[courseCounter]->deptCode>>course[courseCounter]->courseNumber; course[courseCounter]->name = iss.str().substr(iss.tellg()); courseCounter++; break; case 'A': iss>>newISBN; int deptCode, courseNum, courseIndex; iss>>deptCode>>courseNum; courseIndex = getCourse( courseNum, deptCode); bookIndex = getBook( newISBN); classes[classCounter] = new Class; classes[classCounter]->book = books[bookIndex]; classes[classCounter]->course = course[courseIndex]; iss>>classes[classCounter]->sectionNumber; iss>>classes[classCounter]->required; classCounter++; break; case 'G': printBooks(code, iss); break; case 'P': printAllInfo(code, iss); break; } } } }