im in the final stages of writing mastermind and im down to the white pegs
i have 2 char arrays with 4 elements in each i.e

userguess[4]
answer[4] the answer is randomly generated

i need to compare them with each other so if the user guesses for example R i need to search through answer and see if there are any R's more importantly which location they are in and if they are in the same location i.e

userguess[0] = 'R'
answer[0] = 'R'

if they are in the same location i need to ignore it as that would generate a black peg however if they are in different locations i.e

userguess[0] = 'R'
answer[1] = 'R' or answer[2],answer[3]

then i need to add 1 to my white count. I got that working however my problem comes when there is more than 1 'R' in answer[x] i tried using the following method which went wrong

if guess[0] = answer[1],answer[2],answer[3]
guess[1] = answer[0],answer[2], answer[3]
etc.......

i know thats not the correct syntax! somehow i think i need to change it so if answer1, 2 or 3 are the same it deducts 1 from the white count? i tried this with lots of if statements it compiled but crashed every time it tried to work out the white count. i would post my code but its seriously long. Can anyone point me in the right direction even if its a different way of doing it sorry for the essay!! thanks