The following is code from one of my functions. This particular function's goal is to get how many users are playing, and to get all of their names. If two or more of their names are the same then it will make a bool (error) true. I got the idea of comparing them from a bubble sort. For some reason I get a weird error that pops out and it ask me to break or continue(you probably know what annoying error I'm talking about). If I go back to the debug, it works, but it is frozen.
int num_players;
bool error=false;
while(true){
system("cls");
cout<<"How many people will be playing?"<<endl;
cin>>num_players;
cin.ignore();
if(num_players==1)
{
cout<<"You can't choose only 1 player in Multi-Player"<<endl;
pause();
system("cls");
}
if(num_players==0)
{
cout<<"Very funny pal. You can't pick 0 players in ANY game mode."<<endl;
pause();
system("cls");
}
elseif(num_players>=2)
{
break;
}
}
for(int i=0; i<num_players; i++)
{
players.push_back(fighter());
}
system("cls");
while(true)
{
for(int i=0; i<players.size();i++)
{
cout<<"Please enter in the names of the players"<<endl;
getline(cin, players[i].name);
system("cls");
}
for(int a=0; a<players.size(); a++)
{
if(players[a].name==players[a+1].name)
{
error=true;
}
else;
}
if(error==true)
{
cout<<"Two or more players have the same name."<<endl;
for(int a=0;a<num_players;a++)
{
players.pop_back();
}
}
elseif(error==false) break;
}