I need to find the given words in a 8*8 grid. Then change the characters of found world with #. Then print the last version of the grid. I couldn't make a loop for changing the characters.
What I have tried:
#include <stdio.h>
#include <string.h>
int main()
{
int x[]={-1,-1,-1,0,0,1,1,1};
int y[]={-1,0,1,-1,1,-1,0,1};
int i,j,wordnum,r,c;
char in[8][8];
char out[8][8];
char words[8][15];
char word[8];
int len;
for(i=0;i<8;i++)
{
for(j=0;j<8;j++){
scanf(" %c\n",&in[i][j]);
}
}
scanf("%d\n", &wordnum);
for(i=0;i<8;i++)
{
for(j=0;j<8;j++){
scanf(" %c\n",&words[i][j]);
}
}
len = strlen(words[i]);
for(i=0;i<8;i++)
{
for(j=0;j<8;j++){
out[i][j]=in[i][j];
}
}
for (i=0;i<8;i++){
for(j=0;j<8;j++){
if (in[i][j]==words[i][j]){
i+=x[i];
}
else if (in[i][j]==words[i][j]){
j+=y[i];
}
else {
break;
}
}
}
for(i=0;i<8;i++)
{
for(j=0;j<8;j++){
printf("%c",out[i][j]);
}
printf("\n");
}
return 0;
}