## Knight's Tour Problem help?

I was trying to solve the Knight;s tour in C. Basically, I have encodded the starting point. Well heres my question. Suppose I entered the knight's starting position(e.g. A1), and my code will print an output like this:

A B C D E F G H
8 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0
5 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0

I just want to know how can I make the knight jump onto either B3 or C2 and not go out of bounds? The reason for this is because we have a priority array:

2, 3, 4, 4, 4, 4, 3, 2,
3, 4, 6, 6, 6, 6, 4, 3,
4, 6, 8, 8, 8, 8, 6, 4,
4, 6, 8, 8, 8, 8, 6, 4,
4, 6, 8, 8, 8, 8, 6, 4,
4, 6, 8, 8, 8, 8, 6, 4,
3, 4, 6, 6, 6, 6, 4, 3,
2, 3, 4, 4, 4, 4, 3, 2

and the knight can either go to the lowest number in the priority array, thus it is not necessary for the whole board to have a value. That's it. I'm not asking for the full code of the knight's tour, I just want to ask how or what algorithm should I use so that the knight, from A1, can go to either B3 or C2. Thanks! Btw, if You're willing to read, heres my code:

Code:
// this is a Machine Problem - THE KNIGHT'S TOUR

#include <stdio.h>

int main()
{
// INITIALIZING THE CHESS BOARD
char c, d;
int a, b;
int board[8][8]={0};
int aray[]={0};

// INITIALIZING THE PRIORITY BOARD
int i, j;
int prio[8][8] = {{1,2,3,3,3,3,2,1},
{2,3,4,4,4,4,3,2},
{3,4,5,5,5,5,4,3},
{3,4,5,5,5,5,4,3},
{3,4,5,5,5,5,4,3},
{3,4,5,5,5,5,4,3},
{2,3,4,4,4,4,3,2},
{1,2,3,3,3,3,2,1}};

//Initializing moves
int horizontal[]={2,1,-1,-2,-2, -1,1,2};
int vertical[]={-1,-2,-2,-1,1,2,2,1};

// STARTING POINT
printf("Starting Point: ");
scanf("%c%c", &c, &d);

//if statements are to be used
if (d=='8'){
if (c=='A')
board[0][0]=1;
else if (c=='B')
board[0][1]=1;
else if (c=='C')
board[0][2]=1;
else if (c=='D')
board[0][3]=1;
else if (c=='E')
board[0][4]=1;
else if (c=='F')
board[0][5]=1;
else if (c=='G')
board[0][6]=1;
else if (c=='H')
board[0][7]=1;
else{return 0;}
}
else if (d=='7'){
if (c=='A')
board[1][0]=1;
else if (c=='B')
board[1][1]=1;
else if (c=='C')
board[1][2]=1;
else if (c=='D')
board[1][3]=1;
else if (c=='E')
board[1][4]=1;
else if (c=='F')
board[1][5]=1;
else if (c=='G')
board[1][6]=1;
else if (c=='H')
board[1][7]=1;
else{return 0;}
}
else if (d=='6'){
if (c=='A')
board[2][0]=1;
else if (c=='B')
board[2][1]=1;
else if (c=='C')
board[2][2]=1;
else if (c=='D')
board[2][3]=1;
else if (c=='E')
board[2][4]=1;
else if (c=='F')
board[2][5]=1;
else if (c=='G')
board[2][6]=1;
else if (c=='H')
board[2][7]=1;
else{return 0;}
}
else if (d=='5'){
if (c=='A')
board[3][0]=1;
else if (c=='B')
board[3][1]=1;
else if (c=='C')
board[3][2]=1;
else if (c=='D')
board[3][3]=1;
else if (c=='E')
board[3][4]=1;
else if (c=='F')
board[3][5]=1;
else if (c=='G')
board[3][6]=1;
else if (c=='H')
board[3][7]=1;
else{return 0;}
}
else if (d=='4'){
if (c=='A')
board[4][0]=1;
else if (c=='B')
board[4][1]=1;
else if (c=='C')
board[4][2]=1;
else if (c=='D')
board[4][3]=1;
else if (c=='E')
board[4][4]=1;
else if (c=='F')
board[4][5]=1;
else if (c=='G')
board[4][6]=1;
else if (c=='H')
board[4][7]=1;
else{return 0;}
}
else if (d=='3'){
if (c=='A')
board[5][0]=1;
else if (c=='B')
board[5][1]=1;
else if (c=='C')
board[5][2]=1;
else if (c=='D')
board[5][3]=1;
else if (c=='E')
board[5][4]=1;
else if (c=='F')
board[5][5]=1;
else if (c=='G')
board[5][6]=1;
else if (c=='H')
board[5][7]=1;
else{return 0;}
}
else if (d=='2'){
if (c=='A')
board[6][0]=1;
else if (c=='B')
board[6][1]=1;
else if (c=='C')
board[6][2]=1;
else if (c=='D')
board[6][3]=1;
else if (c=='E')
board[6][4]=1;
else if (c=='F')
board[6][5]=1;
else if (c=='G')
board[6][6]=1;
else if (c=='H')
board[6][7]=1;
else{return 0;}
}
else if (d=='1'){
if (c=='A')
board[7][0]=1;
else if (c=='B')
board[7][1]=1;
else if (c=='C')
board[7][2]=1;
else if (c=='D')
board[7][3]=1;
else if (c=='E')
board[7][4]=1;
else if (c=='F')
board[7][5]=1;
else if (c=='G')
board[7][6]=1;
else if (c=='H')
board[7][7]=1;
else{return 0;}
}
else{return 0;}

//printing board
for (i = 0; i < 8; i++)
{
printf("\n");
for (j = 0; j < 8; j++)
{
printf("%2d ", board[i][j]);

}
}

printf("\n");

return 0;
}