hello,
i have been writing a program to sort names from one file and numbers from another file.
i have the files being read in. each contains 1500 names or numbers. i have to sort the names alphabetically and the numbers have to move with the name it corresponds to. right now each name is matched with the number in the opposit file. i know that i have to use the function called sort.
can anyone give me an example of how to sort alphabetically???? and also change the numbers list at the same time?
thanks
this is m code so far:
// Include Section
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
// Main Program
int main( )
{
// Constant Declarations
char names[1500][30];//names arrray from input
char nums[1500][30];//number arrray from input
int i=0; //sets i to 0 for counting numbers
int n=0; //sets n to 0 for counting names
int end;// end of the input
// Output Identification
system("CLS");
cout << "In Class 13 by Adam Zankowski- "
<< "Lookup\n\n";
ifstream in_streamname;
in_streamname.open("E:\\phonenumberlookup\\phoneNames.txt");
if (in_streamname.fail())//opens names file and test for fail
{
cout <<"input file opening failed.\n";
}
while (! in_streamname.eof())// reads names
{
in_streamname.getline(names[n],30);
n++;
}
ifstream in_streamnum;
in_streamnum.open("E:\\phonenumberlookup\\phoneNums.txt");
if (in_streamnum.fail()) //opens and test for fail
{
cout <<"input file opening failed.\n";
}
while (! in_streamnum.eof())//reads input from file
{
in_streamnum.getline(nums[i],30);
i++;
}
end=i;
in_streamname.close();//closes input file
in_streamnum.close();//closes input file
do
{
void sort ( )
}
cout << "\n\nEnd Program.\n";
return 0;
}