I can't figure out how to keep it from running off the array and going crazy.
I tried a few functions, but they either get rid of my output or funk it up.
I want the knight to be a 3 the kill spots a zero and everything else a 1.
if you pick anything on the outside it usually errors out.
thanks, dcmiller
aka netjet
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/* Knight program - basic*/
# include <stdio.h>
int main(void)
{
/* declare varibles */
int b[8][8],*ptr=&b[0][0],k,i=0,j=0,row,column;
double ROW,COLUMN;
/* set all spaces to 1 */
for(k=0;k<=63;k++)
*(ptr+k)=1;
/* ask user for row and column */
printf(" enter value for row to place 'Knight' (0-7) \n");
scanf("%i",&row);
printf(" enter a value for the column to place 'Knight' (0-7) \n");
scanf("%i",&column);
ROW=row;
COLUMN=column;
/* make all spaces with hits 0's */
b[column-2][row+1]=0;
b[column-2][row-1]=0;
b[column+2][row-1]=0;
b[column+2][row+1]=0;
b[column-1][row+2]=0;
b[column-1][row-2]=0;
b[column+1][row+2]=0;
b[column+1][row-2]=0;
for(i=0;i<=7;i++)
{
for(j=0;j<=7;j++)
{
/* make space where Knight is a 3 */
b[row][column]=3;
/* print values */
printf(" %i",b[i][j]);
}
printf(" \n");
}
return 0;
}