I'm writing a function that compares two different character arrays of 3 to 6 dimensions for exact and inexact matches. It returns the number of exact and inexact matches via output parameters.

For some reason I'm getting huge numbers for the matches, can you help me figure out what is wrong?

[code]Code:int calcMatches(char answer[], int dim, Guess guess, int *exact, int *inexact) { int j, count = 0, decount = 0; /*inexact matches algorithm*/ if(dim == 3) { if(answer[0] == guess.letters[1]) /*first term*/ *inexact = count + 1; /*first term*/ else if(answer[0] == guess.letters[2]) /*first term*/ *inexact = count + 1; /*first term*/ else if(answer[1] == guess.letters[0]) /*2nd term*/ *inexact = count+1; /*2nd term*/ else if(answer[1] == guess.letters[2]) /*2nd term*/ *inexact = count+1; /*2nd term*/ else if(answer[2] == guess.letters[0]) *inexact = count + 1; else if(answer[2] == guess.letters[1]) *inexact = count+1; } if(dim == 4) { if(answer[0] == guess.letters[1]) /*first term*/ *inexact = count + 1; /*first term*/ if(answer[0] == guess.letters[2]) /*first term*/ *inexact = count + 1; /*first term*/ if(answer[0] == guess.letters[3]) *inexact = count + 1; if(answer[1] == guess.letters[0]) /*2nd term*/ *inexact = count + 1; /*2nd term*/ if(answer[1] == guess.letters[2]) /*2nd term*/ *inexact = count + 1; /*2nd term*/ if(answer[1] == guess.letters[3]) *inexact = count + 1; if(answer[2] == guess.letters[0]) *inexact = count + 1; if(answer[2] == guess.letters[1]) *inexact = count + 1; if(answer[2] == guess.letters[3]) *inexact = count + 1; for(j=0; j<(dim-1); j++) if(answer[3] == guess.letters[j]) *inexact = count + 1; } if(dim == 5) { for(j=1; j<dim; j++) if(answer[0] == guess.letters[j]) /*first term*/ *inexact = count + 1; if(answer[1] == guess.letters[0]) /*2nd term*/ *inexact = count + 1; for(j=2; j<dim; j++) if(answer[1] == guess. letters[j]) *inexact = count + 1; if(answer[2] == guess.letters[0]) *inexact = count + 1; if(answer[2] == guess.letters[1]) /*3rd term*/ *inexact = count + 1; for(j=3; j<dim; j++) if(answer[2] == guess.letters[j]) *inexact = count + 1; for(j=0; j<3; j++) if(answer[3] == guess.letters[j]) /*4th term*/ *inexact = count + 1; if(answer[3] == guess.letters[4]) *inexact = count + 1; for(j=0; j<(4); j++) if(answer[4] == guess.letters[j]) /*5th term*/ *inexact = count + 1; } if(dim == 6) { for(j=1; j<dim; j++) if(answer[0] == guess.letters[j]) /*first term*/ *inexact = count + 1; if(answer[1] == guess.letters[0]) /*2nd term*/ *inexact = count + 1; for(j=2; j<dim; j++) if(answer[1] == guess.letters[j]) *inexact = count + 1; if(answer[2] == guess.letters[0]) *inexact = count + 1; if(answer[2] == guess.letters[1]) /*3rd term*/ *inexact = count + 1; for(j=3; j<dim; j++) if(answer[2] == guess.letters[j]) *inexact = count + 1; for(j=0; j<(3); j++) if(answer[3] == guess.letters[j]) /*4th term*/ *inexact = count + 1; if(answer[3] == guess.letters[4]) *inexact = count + 1; if(answer[3] == guess.letters[5]) *inexact = count + 1; for(j=0; j<4; j++) if(answer[4] == guess.letters[j]) /*5th term*/ *inexact = count + 1; if(answer[4] == guess.letters[5]) *inexact = count + 1; for(j=0; j<5; j++) if(answer[5] == guess.letters[j]) /*6th term*/ *inexact = count + 1; } /*exact matches algorithm*/ for(j=0; j<dim; j++){ if(answer[j] == guess.letters[j]) *exact = decount + 1; } }