codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  sorting 2 arrays  inssanity21 at 21:16 on Sunday, November 23, 2008
 

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[2000][30];//names arrray from input
char nums[2000][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,30);
i++;
}
end=i;

in_streamname.close();//closes input file
in_streamnum.close();//closes input file
do
{





}


cout << "\n\nEnd Program.\n";

return 0;
}









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
• Regular Expression Query Replace -- Twice Wrongly
• Processing MS Office documents with Java
• Re: help!
• Re: Can javascript preload swf files?
• ADODB.Recordset error (0x800A0CB3)
• Need Your Inputs About Level Editor Interface
• `section` is an unexpected token. Expecting white space. Line 1, position 137.
• Javascript rollover toggle help please!
• help monitoting cpu load on windows machine


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009