#include<iostream>
#include<string>
#include<ctime>
usingnamespace std;
void Spin(int&,int);
void Spin(int& spinner,int i)
{
srand(time(NULL));
spinner=rand()%6+1;
}
int main()
{
int space[4];
int number;
int i=0;
int spinner;
int win;
string answer;
cout<<"Enter how many players you want."<<endl;
cin>>number;
for (i=0;i<=number+1;i++)
{
space[i]=0;
i++;
}
cout<<"Everone starts on space 0."<<endl;
win=1;
while(win==1)
{
cout<<"?"<<endl; // PRINTS "?" INFINITELY
for (i=1;i<=number;i++)
{
if (space[0]<100&&space[1]<100&&space[2]<100&&space[3]<100&&space[4]<100)
{
cout<<"Player "<<i<<" type something in to continue."<<endl;
cin>>answer;
Spin(spinner,i);
space[i]=space[i]+spinner;
if (space[i]>=100)
{
space[i]=100;
}
cout<<"Player "<<i<<" spun a "<<spinner<<". "<<endl;
cout<<"You are now on space "<<space[i]<<"."<<endl;
if (space[i]==4)
{
cout<<"You donated blood. You advance to space 14."<<endl;
space[i]=14;
}
if (space[i]==9)
{
cout<<"You won the pie-eating contest. You advance to space 31."<<endl;
space[i]=31;
}
if (space[i]==16)
{
cout<<"You knocked a bookcase over. You go back to space 6."<<endl;
space[i]=6;
}
if (space[i]==21)
{
cout<<"You won the pet show. You advance to space 42."<<endl;
space[i]=42;
}
if (space[i]==28)
{
cout<<"You won the lottery! You advance to space 84."<<endl;
space[i]=84;
}
if (space[i]==36)
{
cout<<"You baked a cake for your mother. You advance to space 44."<<endl;
space[i]=44;
}
if (space[i]==47)
{
cout<<"You lost your favorite book. You go back to space 26."<<endl;
space[i]=26;
}
if (space[i]==49)
{
cout<<"You forgot your mother's birthday. You go back to space 11."<<endl;
space[i]=11;
}
if (space[i]==51)
{
cout<<"You helped a cat get out of a tree. You advance to space 67."<<endl;
space[i]=67;
}
if (space[i]==56)
{
cout<<"You didn't feed your pet. You go back to space 53."<<endl;
space[i]=53;
}
if (space[i]==62)
{
cout<<"You failed a big test. You go back to space 19."<<endl;
space[i]=19;
}
if (space[i]==64)
{
cout<<"You lost your pet. You go back to space 60."<<endl;
space[i]=60;
}
if (space[i]==71)
{
cout<<"You got an 'A' on a big test. You advance to space 91."<<endl;
space[i]=91;
}
if (space[i]==80)
{
cout<<"You have discovered a cure for cancer. You advance to space 100, YOU WIN!"<<endl;
space[i]=100;
}
if (space[i]==87)
{
cout<<"You crashed your parents' car. You go back to space 24."<<endl;
space[i]=24;
}
if (space[i]==93)
{
cout<<"You broke the TV. You go back to space 73."<<endl;
space[i]=73;
}
if (space[i]==95)
{
cout<<"You spilled the paint on the floor. You go back to space 75."<<endl;
space[i]=75;
}
if (space[i]==98)
{
cout<<"You caught the flu. You go back to space 78."<<endl;
space[i]=79;
}
if (space[i]>=100)
{
cout<<"Player "<<i<<" YOU WIN!"<<endl;
win=2;
}
}
}
}
return 0;
}
space is an array with 4 possible indexes ranging from 0 to 3.
In line 24 you make no effort to assure number is within that range.
In lines 25 and 39 you use number to determine index values into space.
In line 41 you access space[4] which results in undefined behavior.
You probably want to move line 10 into main. Seeding the random number generator is something you generally only need to do once per run.
The problem you asked about, though is line 25. When the program begins you set some arbitrary number of values in space to 0. In line 25, the if expression never evaluates to true unless every member of space is > 100.