Ok, my puzzle program is almost complete. I just can't figure out how to swap the number the user chooses to put in the blank space, and the blank space.

Here's the function that sees if the move is valid and if it is, calls swap to switch the number to move and the blank space

And here's the swap functionCode:int doMove(int puzzle[][PUZZLE_SIDE], int move) { int j = 0; int k = 0; int a = 0; int b = 0; for(j = 0; j < 4; j++) { for(k = 0; k < 4; k++) // Loop through the puzzle { if(puzzle[j][k] == move) // If the position in the puzzle array is equal to the number to user wants to move, set a and b to the row { // and column of this position a = j; b = k; } } } if(puzzle[a-1][b] == 0 || puzzle[a+1][b] == 0 || puzzle[a][b-1] == 0 || puzzle[a][b+1] == 0) // If the row immediately above or below { // the number to move is 0 (in the same column) swap(&a,&b); // or if the column to the immediate return 1; // left or right of the number (in the same row) } // is 0, the move is valid and 1 is returned. else { return 0; // Otherwise the move is invalid and 0 is returned. } }

Code:void swap(int *a, int *b) { int temp; temp = *a; *a = *b; *b = temp; }