// FILENAME: dogracer.cpp // Written by Darin Gillis // gillisd@colorado.edu // This program will utilize file input/output so that it // will take a greyhound racing program and handicap the dogs // as directed by a book i read. // ** NOTE in order for file to be "readable", // the racing program is cut down to one race, & all of the // 2-digit nums in one-eigth & stretch must be truncated // and the race header is also removed. #include // Provides EXIT_FAILURE, EXIT_SUCCESS, atoi #include // Provides external file streams #include // Provides cin, cout, cerr #include "dograce.h" // Provides Dograce Class // GLOBAL DECLARATIONS //************************* Main **************************** int main() { char in_file[40]; // arrays to hold in/out file names ifstream ins; // Input file stream containing a dog race int dognum, score[8]; float rec; Dograce *dograce; // Open input and output file, exit on any error cout << "Please type the encoded file name: "; cin >> in_file; ins.open(in_file); if (ins.fail()) { cerr << "<<< - ERROR: Cannot open " << in_file << " for input. - >>>" << endl; return EXIT_FAILURE; } cout << "Please enter the course record: "; cin >> rec; // INIT score array for (dognum=0;dognum<8;dognum++) score[dognum]=0; // Fill the dogs with information dograce = new Dograce(rec); dograce->filldogs(ins); dograce->getscore(score); for (dognum=0;dognum < 8;dognum++) cout << " Number " << (dognum+1) << " dog gets a " << score[dognum] << endl; // CLEANUP ins.close(); delete dograce; // pause program cin.ignore(); cin.ignore(); return EXIT_SUCCESS; }