I liked using getche() from conio.h, to get the keys, and had a menu like this:
Code:
do {
gotoxy(54,12);
printf(" ");
gotoxy(5,12);
printf("Moves are: up, down, left, or right (q to quit) [u/d/l/r/q]: ");
//scanf(" %c", &ch);
ch = getche();
// r = getchar();
switch (ch) {
case 'u': up(); break;
case 'd': down(); break;
case 'l': left(); break;
case 'r': right(); break;
case 'q': return;
default:
gotoxy(5,12);
printf("That's not a move, please try again ");
sleep(1);
}
printGrid();
}while(!isDone());
Other alternatives are to use getchar() or even scanf() (but remember to add the getchar() after them to remove the trailing newline from the keyboard buffer).
Do you have conio.h on your compiler's header files?
I recall playing with one while we drove across crountry as a kid. The odd thing about this puzzle is that it has a "left" and "right" arrangement to it. The "right" way, you can solve it. If it's set up with the "left" type of configuration, it can not be solved, though you try your hardest. It will always be one tile out of place. Google on that (but they don't call it left and right configuration, they have high-faluting names for it, of course).
Rather famously, some guy made zillions of these sliding puzzles, and they were pre-set so you couldn't solve them! Had everybody scratching their heads for a long while. It was a fad, back in the 50's.