@Dee,
If you insist on using spaces between elements then you can use a 2-d int array or vector of vectors instead of the char array implied by using strings. That is the only change.
It would take very little for you to transform grid[] in the code above to such an array. So I think you could do that yourself.
BTW. Make sure that your latest 4x4 example is feasible. It has no route between top left and bottom right.