Shortest path from a source cell to a destination cell of a Binary Matrix through cells consisting only of 1s

#include
using namespace std;
  
#define ROW 4
#define COL 4
  

struct Point {
    int x, y;
};
  

struct Node {
    Point pt;
    int dist;
};
  

bool isValid(int row, int col)
{
    return (row >= 0) && (col >= 0)
           && (row < ROW) && (col < COL); }    int dRow[] = { -1, 0, 0, 1 }; int dCol[] = { 0, -1, 1, 0 };    void pathMoves(char mat[][COL],                Point src, Point dest) {               int d[ROW][COL];     memset(d, -1, sizeof d);             d[src.x][src.y] = 0;             bool visited[ROW][COL];     memset(visited, false, sizeof visited);             visited[src.x][src.y] = true;             queue q;             Node s = { src, 0 };             q.push(s);                  bool ok = false;             while (!q.empty()) {                     Node curr = q.front();         Point pt = curr.pt;                              if (pt.x == dest.x             && pt.y == dest.y) {                int xx = pt.x, yy = pt.y;             int dist = curr.dist;                                                       d[pt.x][pt.y] = dist;                             string pathmoves = "";                             while (xx != src.x                    || yy != src.y) {                                     if (xx > 0 && d[xx – 1][yy] == dist – 1) {
                    pathmoves += ‘D’;
                    xx–;
                }
  
                
                if (xx < ROW - 1                     && d[xx + 1][yy]                            == dist - 1) {                     pathmoves += 'U';                     xx++;                 }                                     if (yy > 0 && d[xx][yy – 1] == dist – 1) {
                    pathmoves += ‘R’;
                    yy–;
                }
  
                
                if (yy < COL - 1                     && d[xx][yy + 1]                            == dist - 1) {                     pathmoves += 'L';                     yy++;                 }                 dist--;             }                             reverse(pathmoves.begin(),                     pathmoves.end());                cout