Hi,
I have registered myself,as I suppose
I was violating the rule of being unregistered
and asking Qs,so pls atleast now help me out!!
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 when I type in the right ID then too
it displays the message
"ID not found"
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:
validCompName = validateCompetitorName(compName);
result = checkDup(database,validCompName);
int index = unsortedFind(database,tmprec, validCompName);
if(result==1)
{
if(index!=-1)
{
while(index<tmprec)
{
...display that particular records... index ++;
}
}
cout<<"Multiple entries found"<<endl;
cout<<"pls type ID"<<endl;
sID = getID();
validID = validateID(sID,tmprec);
ID = atoi(validID.c_str());
if(database[index].ID!= ID)
{
cout<<"ID not found"<<endl;
displayMainMenu();
option =getMenuOption();
}
else if(database[index].ID==ID)
{
compName = getCompetitorName();
validCompName = validateCompetitorName(compName);
:
:
cout<<"record edited"<<endl;
}
int checkDup ( competitor database[], string name )
{
for(int x= 0; x<DATABASESIZE;x++)
{
if ( database[x].competitorName == name )
count++;
}
return ( count > 1 ) ? 1 : 0;
}
int unsortedFind(const competitor database[], const int tmprec, string name)//tmrec = no. of records currently in an array
{
while(index <tmprec)
{
if (name == database[index].competitorName)
{
result = index;
index = tmprec;
}
else
index++;
}
return result;
}