Hello again. Another noob question. We're doing a project in class, I'm having an issue with getting the computer to read some input correctly, and I can't find a solution in the textbook.
Normally I have some code to offer but I can't even figure that much out >.< I tried putting something together, not so much for the project, but to just try and get the program to read the input file right.
int main()
{
// first letter of the hometown
string pos, fname, lname, home, c_lass, prevSchool; //
int count = 0; // number of mnames in the file
int loc;
int number;
int weight, ftHeight, inHeight; // where is DE ?
//
//
string filename; // name of the input file
ifstream inFile; // input file stream variable
cout << "Enter the name of the input file: " ;
cin >> filename;
inFile.open(filename.c_str () );
if (!inFile)
{
cout << "Incorrect file name \n\n";
return 1;
}
cout << filename << " was opened" << endl<<endl;
// ignore the first line
inFile.ignore ( 0, '\n');
inFile >> number;
inFile >> fname;
inFile >> lname;
inFile >> pos;
inFile >> c_lass;
inFile >> ftHeight;
inFile >> inHeight;
inFile >> weight;
inFile >> home;
inFile >> prevSchool;
cout << number << " " << fname << " " << lname << " " << pos << " " << c_lass << " " << ftHeight << inHeight << " " << weight << " " << home << " " << prevSchool << endl;
and the input file is as follows:
1 2 3 4 5 6 7 8 9 10 11
NO NAME POS CLASS HEIGHT WEIGHT Hometown/High School/Last College
60 Josh Mann OL SO 6-4 300 Virginia Beach, Va./Ocean Lakes
64 Ricky Segers K/P FR 5-11 185 Glen Allen, Va./Henrico
70 Brandon Carr OL RS_SR 6-2 305 Chesapeake, Va./Western Branch/Fork Union Military Academy
53 Calvert Cook LB FR 6-0 250 Norfolk, Va./Booker T. Washington
51 Michael Colbert DE RS_SR 6-1 230 Fayetteville, N.C./E.E. Smith
22 T.J. Cowart CB RS_JR 5-9 190 Virginia Beach, Va./Ocean Lakes
1 Jakwail Bailey WR SO 5-11 185 Haddonfield, N.J./Paul VI
25 Andre Simmons S JR 6-0 205 Lorton, Va./South County/Vanderbilt
34 Johnel Anderson RB FR 5-8 180 Sicklerville, N.J./Paul VI
I can't figure out how to get the program to read the hometown right. Thoughts? Ideas?