I can't get my head of how the code compile because of the 2 times we need to call for n-1 to set it as the concept.
The code:
void tower(int n, char A, char B, char C)
{
if (n == 0)
return;
else
{
tower(n - 1, A, C, B);
printf("Disk %d from %c to %c\n", n, A, B);
tower(n - 1, C, B, A);
}
}
int main()
{
tower(3, 'A', 'B', 'C');
}
Can someone help with to understand how it is execute in the compiler/stack for each step?
Hope you guys can help me with that. Thanks!