Hi,
Sorry forgot the codetag!
the Q is if there are multiples of a single name in the database ,that records should be displayed and user should be asked to type in the ID.....for which particular name he wants to make changes.......
I was able to find duplicate names but I just cant understand how to display that specific duplicate records......
If I run this code .......it just displays 0 0 0 0
Multiple entries found.......
please enter ID
Please look at my code,and pls let me know where I am going wrong......
I would really appreciate if someone help this beginner.
Code:
int position =-1;
validCompName = validateCompetitorName(compName);
result = checkDup(database,validCompName);
if(result==1)
{
for(int i=0; i<tmprec;i++)
{
if(database[i].competitorName ==validCompName)
{
position = i;
i= DATABASESIZE;
if(position!=-1)
{
cout<<database[i].competitorName<<" "
<<database[i].ID<<" "<< database[i].birthDate.day<<" "<<
database[i].birthDate.month<<" "<<
database[i].birthDate.year<<endl;
cout<<Multiple entries found"<<endl;
cout<<"pls type ID"<<endl;
sID = getID();
validID = validateID(sID,tmprec);
ID = atoi(validID.c_str());
if(database[i].ID!= ID)
{
cout<<"ID not found"<<endl;
displayMainMenu();
option =getMenuOption();
activateMenu( option , tmprec , tempID, latID);
}
}//if position
}//if
}//for
}//if result
int checkDup ( competitor database[], string name )
{
int count = 0;
for(int x= 0; x<DATABASESIZE;x++)
{
if ( database[x].competitorName == name )
count++;
}
return ( count > 1 ) ? 1 : 0;
}