I'm completely stumped. I can initialize my array and randomize it using the names that I have in my array, but I cannot error check it so that it appears only once in the array. Therefore the names becomes duplicates which I'm not supposed to have. Any help would be appreciated. Here's my code:
///////////////CODE////////////////////////////////////////////
string NameArray[5] = {"KillerJohn" , "GerNater" , "DemonJosh","CyborgEmily", "SuperJoe"};
cout<< "Before the Name Random\n";
for (int i =0; i <=4; i++)
{
cout << NameArray[i] << endl;
}
cout << endl;
cout <<"After the randomizing\n";
srand(time(0));
for (int j =0; j<=4; j++)
{
string Random;
Random = NameArray[rand()%5];
cout << Random << endl;
NameArray[j] = Random ;
}
/////////////////END////////////////////
This code is in a class assuming I have all the common libraries.