focusing on 'bool checkIfCorrect function and main, ignore the rest
I'm trying to get CheckIfCorrect run and see if there are matches with the compcards[](five random numbers) array which I generated with another function.
Checkifcorrect only works if you guess right the first time other than that It doesn't work. Could anyone help?
bool checkIfCorrect(int checkcard, int compcards[], int player[]){
for (int i=0; i<5; i++)
{
if(compcards[i] == checkcard)
cout<<"correct"<< endl;
returntrue; //You return true here on every loop
}
returnfalse;
}
I think what you intended on doing was have lines 7 and 8 inside of the if statement. Otherwise the function will return true regardless: