Hi,

I really have difficulty understand how the program 'tower of hanoi' really works. I obtained the source code from Zahid and can anyone a comment after each line explaining what it does ?

thnx in advance

Code:
/* t_of_hanoi.c */

#include<stdio.h>
int shift( int, int, int );
static int move = 0;

int main()
{
   int disk;
   printf("Number of disk:");
   scanf("%d",&disk);

   shift_disk(1,3,disk);

   printf("\nAll disks shifted: %d Move\n",move);
   printf("Successfully done!!\n\n");
   printf("====================================\n");
   printf("= Programmed by                    =\n");
   printf("= Zahid Hossain, m_z_h@hotmail.com =\n");
   printf("====================================\n");
   getch();
   return 0;
}


int shift_disk(int from, int to, int numdisk)
{
   /* 1,2,3 are the towers*/
   int temp;

   temp = 6 - ( from + to );

   if( numdisk == 0 )
      return 0;

   shift_disk( from, temp, numdisk - 1 );

   printf( "%4d: Move a disk from tower %d to %d\n", ++move, from, to );

   shift_disk( temp, to, numdisk - 1 );

   return 0;

}