Ok I have written this program that will read in a list from another file then spit the file back out into a new one but listed. Now how can i sort this list by alpabetical order using the last name?
Code:#include <iostream.h> #include <fstream.h> #include <stdlib.h> void main() { ifstream inFile; ofstream outFile; char myInFile[] = "a:\\input.txt"; // The inout file. char myOutFile[] = "a:\\output.txt"; // The output file. inFile.open(myInFile); if(inFile){ cout << "\nInput file " << myInFile << " was succesfully opened!!!!" << endl; } else { cout << "\nInput File " << myInFile << " could not be opened!!!!" << endl; exit(-1); } outFile.open(myOutFile); if(outFile){ cout << "\nOutput file " << myOutFile << " was succesfully opened!!!!" << endl; } else { cout << "\nOutput File " << myOutFile << " could not be opened!!!!" << endl; exit(-1); } int account = 0; char fName[20]; char lName[20]; float amount = 0; char dummy; outFile << "This is the data that was read in." <<endl <<endl; inFile >> account >> fName >> lName >> amount; // Prime Read while(inFile){ outFile << account << ' ' << fName << ' ' << lName << ' ' << amount << endl; inFile >> account >> fName >> lName >> amount; } //while outFile << "\nThe end of the input!!!"; }



LinkBack URL
About LinkBacks


