I have many header files for stacks such as pushStack, popStack, destroyStack, etc eg
//stacksADT.h file
#include "P3-06.h" /* Stack ADT Definitions */
#include "P3-07.h" /* Create Stack */
#include "P3-08.h" /* Push Stack */
#include "P3-09.h" /* Pop Stack */
#include "P3-10.h" /* Retrieve Stack Top */
#include "P3-11.h" /* Empty Stack */
#include "P3-12.h" /* Full Stack */
#include "P3-13.h" /* Stack Count */
#include "P3-14.h" /* DestroyStack */
So I wrote the main program to make a simple tower of hanoi using stacks. But I am stuck. I don't know how to use push and pop the elements and how to make the move legally, eg bigger disk cannot put on a smaller disk, etc. Here is my incomplete code:
Just give me any suggestions how can I build a proper tower of hanoi regarding to these problems. Thanks in advance.
#include <stdio.h>
#include <stdbool.h>
#include "stacksADT.h"
#DEFINE smallest 0
int main (void) {
// Local Definitions
void push();
pop();
void hanoi(int N, char source, char dest, char aux);
int* moveDisk;
STACK* stack;
// Statements
stack = createStack ();
printf("Enter a disc(s): ");
scanf ("%d", N);
if (N > 0) {
pushStack(dest, pop(source));
}
else {
hanoi(N - 1, source, dest, aux);
pushStack(dest, pop(source));
hanoi(N - 1, aux, source, dest);
}
void makeLegalMove() {
if (smallest <= source) {
printf("\nThe tower of hanoi\n");
while(!emptyStack(stack)) {
destroyStack (stack);
system("pause");
return 0;
}