I'm having an issue in creating my "Horse Race" program. I'm getting error "subscript requires array or pointer type" in my while(winner==false) loop at
if(q==null)
{
tick[q]++;
}
and
for(int q=0; q<numhor; q++)
{
if(tick[q]==10)
{
...
}
}
in addition to several places in my separate class files, even though I defined the array the beginning of the main.
int main()
{
srand(time(NULL));
int numhor=0, lane=0, null=0, tick=0, winlane=0, x=0, name=0;
int tick[10];
bool winner=false;
string name;
Horse HorseRace[10];
Track TrackRace[10];
cout<<"How many horses will you race? ";
cin>>numhor;
for(int n=0; n<numhor; n++)
{
//cin.ignore();
system("cls");
x=0;
cout<<"Horse #"<<n+1<<endl;
cout<<"Name the horse: ";
cin>>name;
HorseRace[n].nameHorse(name);
//cout<<"Place this horse in lane: ";
//cin>>lane;
system("cls");
HorseRace[n].lane(lane);
TrackRace[n].fillTrack(HorseRace[n], lane);
}
system("cls");
while(winner==false)
{
system("cls");
//null=returnout(numhor);
for(int q=0; q<10; q++) //increases tick number
{
if(q==null)
{
tick[q]++;
}
}
for(int q=0; q<10; q++) //display tick
{
for(int r=0; r<10; r++)
{
cout<<" *";
}
}
for(int q=0; q<numhor; q++) //check for winner
{
if(tick[q]==10)
{
winlane=q;
winner=true;
break;
}
}
time();
}
for(int w=0; w<10; w++)
{
if(HorseRace[w].getlane()==winlane)
{
cout<<HorseRace[w].nameHorse(name)<<" wins!"<<endl;
}
}
getch();
}