I need help using fstream... i need to read a text file that has multiple lines, each line has the syntax: 'fname lname 01 02 03 04 05 06 07 08 08 10' that is a first name space last name space and 10 test scores (separated by spaces). I then have to move all the data from one file to another except i have to add the average of the 10 scores to the end of each line... I can read the full text and display as it is from one file to the other. The problem is i can't read just the numbers in order to get the average...here's the code i have so far... #include #include #include #include using namespace std; #define INPUTFILE "HW660-In.txt" #define OUTPUTFILE "HW660-Out.txt" void rwFiles(ifstream& inSource, ofstream& outSource); bool goOn(); void main() { dispHeader(); do { ifstream inStudentRecord; ofstream outStudentRecord; inStudentRecord.open(INPUTFILE); if (inStudentRecord.fail()) { cout<<"Opening input file failed.\n"; exit(1); }; outStudentRecord.open(OUTPUTFILE); if (outStudentRecord.fail()) { cout<<"Opening output file failed.\n"; exit(1); }; rwFiles(inStudentRecord, outStudentRecord); inStudentRecord.close(); outStudentRecord.close(); }while(goOn()); } void dispHeader() { void rwFiles(ifstream& inSource, ofstream& outSource) { char next; int iGrade = 0, oGrade = 0; inSource.get(next); while (!inSource.eof()) { if(next == '\n') { cout<<" The End"; //this adds "The End" at the end of every line. }; cout<>calcMore; switch (calcMore) { case 'Y': case 'y': ;break; case 'N': case 'n': default: goOn = false; } return goOn; } So basically all my code does is reads exactly what is in the input file and displays it to the screen as well as copies it to the output file. noob in need of help...
afrodriguez
Posts
-
fstream help -
C# Multiple forms...Matt, I didn't ask you for your judgment i asked for some help. You unlike the other guy were of no assistance. Oh btw...I simplified the code down to a textbook manner so that i can get my point across without copying my entire file into the thread...next time give your opinion when asked for it.
-
C# Multiple forms...Thanks that solved my problem.
-
C# Multiple forms...Hi, I had to create my own form to get files from my directory because i had to add allot of functionality not available on the system dialog boxes (done with that) now my problem is i need to pass on the selected files from my directory form to my main form...i can't get this to happen...can anyone help??...this is how i'm calling my second form: private void mnu_Open_Click(object sender, System.EventArgs e) { Form2 myMenu = new Form2(); Menu.Show(); }