Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Plain Text by Javed ( 12 years ago )
#include <iostream>
#include <fstream>
#include <string> 

using namespace std;

struct Athlete
{
    int aID;
    int aAge;
    std::string aName;
    std::string aCountry;
    char aGender;

};  

struct Event
{
       int eID;
       std::string eName;
       std::string eRecord;
};


struct Registration
{
      
       int rID;
       Athlete rAthlete;
       Event rEvent;
       
};


void readregistration(Registration *reg,int &size;) //something is wrong with this function starting from the while loop
{
     string location;
     fstream input;
     char a;
  
     cout<<"Enter File Directory and Name"<<endl;
      // users enter loaction of file;
     
     input.open("C:\\registration.txt");
     
    while(!input.eof())
    {
            for(int i; i < 10; i++){       
             input>>reg[i].rID>>reg[i].rAthlete.aID>>reg[i].rAthlete.aName>>reg[i].rAthlete.aAge>>reg[i].rAthlete.aGender>>reg[i].rAthlete.aCountry>>reg[i].rEvent.eID>>reg[i].rEvent.eName>>reg[i].rEvent.eRecord;                
             }  
          
          input.get(a);
     
    } 

       for(int i = 0; i < 20; i++)
       {
         cout<< reg[i].rID<< reg[i].aID<< reg[i].rAthlete.aName<< reg[i].rAthlete.aAge<< reg[i].rAthlete.aGender<< reg[i].rAthlete.aCountry<< reg[i].rEvent.eID<< reg[i].rEvent.eName<< reg[i].rEvent.eRecord;                
       }           
               
}
     

int main()
{  
    
     Registration registration[20];
    Registration * reg = registration[0]; // doubt here, should it be : ..... *reg = registration ?
    
    
    int size = 20;
    
    cout<<"1.Read and display registration file"<<endl;
    cout<<"2.List all athletes by event"<<endl;
    cout<<"3.List all athletes by country"<<endl;
    cout<<"4.Read and display result file"<<endl;
    cout<<"5.List medal counts by country"<<endl;
    cout<<"6.Display medal tally"<<endl;
    cout<<"7.Exit" <<endl;
   
    
    readregistration(reg,size);
    
    
    system&#40;"pause"&#41;;
    return 0;
}

 

Revise this Paste

Parent: 53639
Your Name: Code Language: