I am so confused. Input # of disks, start peg and end peg. My program is failing miserably yet it is pretty much the exact code that supposedly works. The function keeps subtracting one until it goes haywire. Please see the program and output below. Any help would be appreciated. Thank you in advance.
Code:
#include <stdio.h>
#include <stdlib.h>


// Function Prototypes
void SolveTower(unsigned d, unsigned from, unsigned to, unsigned aux);


// Main Program
int main()
{
    unsigned disks, pegstart, pegend;
    printf("How many disks do you want to move?");
    scanf_s("%u", &disks);
    printf("     From which peg? [1 - 3] --> ");
    scanf_s("%u", &pegstart);
    printf("       To which peg? [1 - 3] --> ");
    scanf_s("%u", &pegend);
    printf("\n======= The Tower of Hanoi Solution ========\n");
    SolveTower(disks, pegstart, pegend, 6 - pegstart - pegend);
    printf("\n============================================\n");
}


// Function Definitions
void SolveTower(unsigned d, unsigned from, unsigned to, unsigned aux)
{
    if (d == 1)
        printf("\nMove a disk from peg %u to peg %u.", from, to);
    else
        printf("\nDisks=%u; From=%u; To=%u; Aux=%u\n", d, from, to, aux); system("pause");  // Debugging code only
        SolveTower(d - 1, from, aux, to);
        printf("\n(ELSE MOVE) Move a disk from peg %u to peg %u.", from, to);
        SolveTower(d - 1, aux, to, from);
}
Output:
How many disks do you want to move?4
From which peg? [1 - 3] --> 1
To which peg? [1 - 3] --> 3


======= The Tower of Hanoi Solution ========


Disks=4; From=1; To=3; Aux=2
Press any key to continue . . .


Disks=3; From=1; To=2; Aux=3
Press any key to continue . . .


Disks=2; From=1; To=3; Aux=2
Press any key to continue . . .


Move a disk from peg 1 to peg 2.Press any key to continue . . .


Disks=0; From=1; To=3; Aux=2
Press any key to continue . . .

Disks=4294967295; From=1; To=2; Aux=3
Press any key to continue . . .

Disks=4294967294; From=1; To=3; Aux=2
Press any key to continue . . .