Can someone please explain to me how to properly use the strcmp
function? I'm creating a tic-tac-toe game and I keep getting the error:
passing argument 1 of ‘strcmp’ makes pointer from integer without a cast
I've created two pointers that act as parameters for the strcmp
function. One is the input that the player puts in, the second is the selection of moves the player has. However, when I try to run the code I get the error above. Below is a piece of my code:
void mark_location(int userU, char str) {
char *moves[] = {"upperLeft", "up", "upperRight", "left", "center", "right", "lowerLeft", "down", "lowerRight"};
if (strcmp(str, moves[0]) == 0)
board[0][0] = userU;
else if (strcmp(str, moves[1]) == 0)
board[0][1] = userU;
else if (strcmp(str, moves[2]) == 0)
board[0][2] = userU;
else if (strcmp(str, moves[3]) == 0)
board[1][0] = userU;
else if (strcmp(str, moves[4]) == 0)
board[1][1] = userU;
else if (strcmp(str, moves[5]) == 0)
board[1][2] = userU;
else if (strcmp(str, moves[6]) == 0)
board[2][0] = userU;
else if (strcmp(str, moves[7]) == 0)
board[2][1] = userU;
else if (strcmp(str, moves[8]) == 0)
board [2][2] = userU;
}