Пример #1
0
/**********************************************************************
 * Add text here to describe what the function "main" does. Also don't forget
 * to fill this out with meaningful text or YOU WILL LOSE POINTS.
 ***********************************************************************/
int main(int argc, const char* argv[])
{
   
   //change this back to 2 to be universal
   if (argc < 1)
   {
      cout << "Usage: a.out fileName\n";
   }
   else
   {
      List<Person> people;
   
      ifstream fin;
      //string fileName = argv[1];
      string fileName = "cameron.ged";
      string tmp;
   
      //Read in file
      do
      {
         fin.clear();
         fin.open(fileName.c_str());
      }
      while(fin.fail());

      Person person;
      //parse file into list
      while(getline(fin, tmp))
      {
         
         if(tmp.substr(0,4) == "0 @I")
         {
            person.idNumber = tmp.substr(4,4);
            fin.ignore();
         }

         if(tmp.substr(0,6) == "2 GIVN")
         {
            person.fname = tmp.substr(6);
         }

         if(tmp.substr(0,6) == "2 SURN")
         {
            person.lname = tmp.substr(6);
         }
         if(tmp.substr(0,6) == "1 BIRT")
         {
            getline(fin, tmp);
            if(tmp.substr(0,6) == "2 DATE")
            {
               person.bday = tmp.substr(6);
            }
         }
         if(tmp.substr(0,6) == "3 TIME")
         {
            people.push_back(person);
            person.clear();
         }

      }

      sortMerge(people);
      
      for(ListIterator<Person> it = people.begin(); it != people.end(); it++)
      {
         (*it).display();
      }


      
      

      //cout << tmp << endl;
   
      //organize by name

      //Put into tree

      //output

   }

   return 0;
}