/* * Begin code I did not write. * This code is partly derived from http://merlot.usc.edu/cs570-f11/homeworks/prog-faq/#cpp_process * If the source code requires you to include copyright, put copyright here. */ void Process(istream& in) { int count = 0; char* buf = new char[MAXBUFSIZE]; in.getline(buf,MAXBUFSIZE); if(strlen(buf)==0) { fprintf(stderr,"Input/File is empty\n"); exit(-1); } My570List *list=new My570List(); ///< CREATING LIST to push all the struct elems while (!in.eof()) { count++; ///< Count all records struct record *temp_str; ///< Create record pointer temp_str = isRecordOk(buf,count); ///< Validate BUFFER and get back record //(void)list->Append((void*)temp_str); ///< Push records into the LIST unsorted SortedInsert(list,temp_str); ///< push records into the list in a sorted manner #ifdef DEBUG1 fprintf(stdout,"%s %d %0.2f %s\n",temp_str->sign,temp_str->timestamp,temp_str->amount,temp_str->description); ///< display record #endif #ifdef DEBUG1 fprintf(stdout,"%s\n",buf); ///< PRINT THE RAW BUFFER #endif in.getline(buf,MAXBUFSIZE); ///< GET THE NEXT LINE } #ifdef DEBUG0 fprintf(stdout,"*******************SORTED DISPLAY*******************\n"); displayRecords(list); ///< DISPLAY THE RECORDS from list #endif tableDisplay(list); ///< DISPLAY FORMATTED OUTPUT!!!! THIS WILL GIVE ME MARKS !!!! :--/ @#@!#! #ifdef DEBUG1 fprintf(stdout,"EOF REACHED\n"); #endif #ifdef DEBUG0 fprintf(stdout,"total number of records processed = %d\n",count); #endif }
void menu(){ char selection[1]; printf("\n1) Create a new record \n2) Display All Records \n3) Update a Record \n4) Exit Program \nPlease enter a valid number to make your choice:\n"); lineFlush(); scanf("%d",selection); lineFlush(); switch(selection[0]){ case 1: createRecord(); break; case 2: displayRecords(); break; case 3: updateRecord(); break; case 4: exit(0); break; default: printf("\nIncorrect option.\n"); break; } }