How would I get this to work?
DISCUSSION: Use the fstream library and the class types, ifstream and ofstream, to declare input and output files. Control the input loop with eof(). During each pass through the loop your program will read an ID and zero to four lap times for each race car. The lap times are terminated with a -1. Your program must read in the lap times by nesting a sentinel (looking for -1) controlled loop inside the eof controlled loop. If a racecar did not complete four laps, it wrecked or had mechanical problems.
INPUT: The input file is named "race1.dat" The data file consists of an unknown number of racecar entries organized so that the information for each vehicle displays an ID number and zero to four lap times measured in seconds. The end of the lap times is marked with a “-1”. The following sample file illustrates how the data are organized. The file is terminated with a hidden <eof> character sequence.
345676
21
17
19
22
-1
456671
24
25
-1 <eof>
OUTPUT: Your program should generate an output file called “race1.out". Remember to label your output. Example:
Vehicle ID Average Speed (Mph) Status
--------------------------------------------------------------
345676 182.3 Mph Qualified
456671 _ DNF
Code:#include<iostream> #include<iomanip> #include<fstream> #include<conio> #include<string> using namespace std; const int sentinel = -1; int main(){ int numin; ifstream input; ofstream out; const int eof = -1; int id; int l1; int l2; int l3; int l4; int race[4]; race[0] = id; race[1] = l1; race[2] = l2; race[3] = l3; race[4] = l4; input.open("race1.dat"); out.open("raceresults.txt"); out << "Vehicle Id Average Speed (Mph) Status" << endl; out << "*********************************************" << endl; int i = 0; for (i=0; i>30; i++){ while (!input.eof()) { do { input >> numin >> race[0]; //input >> numin >> race[1]; //input >> numin >> race[2]; //input >> numin >> race[3]; //input >> numin >> race[4]; } while (numin != sentinel); cout << race[0] << endl; //cout << race[1] << endl; //cout << race[2] << endl; //cout << race[3] << endl; //cout << race[4] << endl; out << race[0] << endl; //out << race[1] << endl; //out << race[2] << endl; //out << race[3] << endl; //out << race[4] << endl; //break; } } input.close(); out.close(); return 0; } //***************************