Need help to edit this code to allow user to find words in the grid that are touching horizontally, vertically, and diagonally adjacent.

For example, the board:

Q W E R T

A S D F G

Z X C V B

Y U A O P

G H J K L

contains the magic words WAS, WAXY, JOB.

# include <stdio.h>

# include <math.h>

# include <stdlib.h>

int lx;

int ly;

char grid [10] [10];

int z;

int j;

int main()

{

// declare array with alphabet

  char alphabet[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',

             'h', 'i', 'j', 'k', 'l', 'm', 'n',

             'o', 'p', 'q', 'r', 's', 't', 'u',

             'v', 'w', 'x', 'y', 'z' };

printf ("Insert the width (Lx) and height (Ly) of the grid \n");

scanf ("%d %d", &lx, &ly);

for (z = 0; z < lx; z++)

 {

  for (j=0; j < ly; j++)

  {

   // print letters instead of dots

   grid [z] [j] = alphabet[rand() % 26];

  }

  }

for (z = 0; z < lx; z++)

 {

  for (j=0; j < ly; j++)

  {

   printf ("%c", grid [z] [j]);

  }

  printf ("\n");

  }

}

A few issues here:

  1. Looks like a duplicate of https://www.daniweb.com/programming/threads/519642/similar-to-boggle-game
  2. I see poor code formatting. Why all those blank lines? Messy!
  3. I see no functions to do a search or such for the words.

Same comment as before: "Let's be clear here. Forums usually just help you past a hurdle such as some line or function that doesn't work. But creating a new app or function or even the full design is your work.

I'll also note that Boggle has already been done many times if you search about that. I can't tell if you just need some boogle code from the web or if this is homework which is a test to see if you understand the course work so far."