text: I have an assignment
  The.
  Im still relatively new to programming so I don't really know where i went wrong i marked where i think the code is messing up and any other pointers you could give would be much appreciated...thank you.. here is the code:
  #include <iostream> #include <string> #include <fstream> using namespace std; int main() { int large, small, ton, iTon, oTon, iCount, oCount; string lname, fname, midInitial; string filename, file2; ifstream infile; large = 0; //for determining max tonnage small = 999; //for determining min tonnage ton = 0; iTon = 0; //idividual Tonnage iCount = 0; //idividual count or number of seasons oTon = 0; //overall tonnage oCount = 0; //overall count of number of seasons cout << "Enter filename: "; cin >> filename; infile.open(filename.c_str()); if(!infile) //test if file opens { cout << "\nError... could not find file...\n"; } do { infile >> lname >> fname >> midInitial; cout << lname << " " << fname << " " << midInitial << "\n"; }while(!infile.eof()); do { file2 = fname + lname + ".dat"; infile.open(file2.c_str()); //having trouble finding this file....is there something wrong with its declaration? if(!infile) { cout << "\nError... could not find file...\n"; } infile >> ton; cout << ton; iTon += ton; iCount++; oTon += ton; oCount++; }while(!infile.eof()); while(ton > large) { large = ton; } while(ton < small) { small = ton; } cout << "\n" << fixed << setprecision(2) << ton; cout << small << " " << large; double avg = iTon/iCount; //to find idividual Avg tonnage double oAvg = oTon/oCount; //to find overall Avg tonnage cout << "\n" << avg << "\n" << oAvg; infile.close(); infile.clear(); return 0; }
  Edited 6 Years Ago by Christoph928: had unused file close and clear (inData.close/clear)