Can someone please help me with a short segment of code I am having trouble with?
Hello,
Can someone please help me understand why my function is not working?
I tried a few different things but below is my best attempt which is still not working like it is suppose to:/
One of my functions in my header file and how I attempted to code it:
Code:
// Pre-conditions: board and answer are of length NUM_PEGS and store the player's
// guess and the correct board, respectively.
// Post-conditions: returns the number of pegs that match at the correct spots.
int numPerfectMatches(int board[NUM_PEGS], int answer[NUM_PEGS]) {
for (i=0; i<NUM_PEGS; i++) {
if (answer==board)
num_perfect+=1
}
part of my program that includes the variables from the header file:
Code:
// Figure out the number of matches.
int num_perfect = numPerfectMatches(board, answer);
int num_imperfect = numWrongPlaceMatches(board, answer);
// Update for this turn.
printf("You have %d perfect matches and %d imperfect matches.\n", num_perfect, num_imperfect);
num_turns++;
NOTE: I am only focusing on "num_perfect" as of right now.
Thank You