I'm trying to return the user input of which row and column to 'switch' (it's supposed to be a game called Teaser), but I'm not sure how to return the value that I want to.
The warning I'm getting is:
warning: incompatible pointer to integer conversion returning 'move *' from a function with result type 'int' [-Wint-conversion]
typedef struct {
int row;
int column;
} move;
/* Function: getNextMove
* Description: Ask the user for a new move or if the user want to quit
* the game.
* Input: A pointer to a move structure. Coordinates for the next move
* or a signal from the user to end the game.
* Output: Return 0 if the user want to end the game, 1 otherwise.
* Return the coordinates for the next game through the
* structure pointed to.
*/
int getNextMove(move *nextMove) {
printf("Make a move (Row = 0 ends the game)\n");
printf("Row = ");
scanf("%d", &nextMove->row);
if (nextMove->row == 0)
{
return 0;
}
printf("Column = ");
scanf("%d", &nextMove->column);
return nextMove;
}
int getNextMove(move *nextMove) {-->move *getNextMove(move *nextMove) {alsoreturn 0;-->return NULL;intand you're returning amove*from it. That's not going to work.int, then that's what it should return. have it return amove *, orint, and change the calling code accordinglyinput:..., output:,... and return:...Withoutputin your code being described asstruct move *, andreturnbeing described as1 for success, 0 for failure, (or whatever your preference is)nextMovewith your implementation, because after invokingmove *move1 = getNextMove(move2),move1will be the same asmove2. In your casereturn nextMove;should be simply replaced byreturn 1;. And you should invoke getnextMove like thisint continuegame = getNextMove(mynextmove).