Just a thought:
Every box you try to move, you'll need to find the depth of the box. Although you'll be pushing on the side of the box facing the robot, the BACK of the box will be the determining factor in how far the box can be pushed.
When the back of the box hits up against a wall, then the whole push must make no more progress, at least until the robot has been re-positioned so it can push the box in a new direction. Then the new back of the box will determine if a push in that direction, can succeed.
In programs like this, working out what you need to do in pseudocode, with pencil and paper, is a real time-saver. Here, I recommend working the same way to solve the problems that remain with your program.
Edit: OK, I see your request for help with the robot's movement. Here's how I'd do it:
1) You have a global CD = robot's current direction
2) Use a switch statement to then determine which way the robot should turn, in psuedocode, something like:
Code:
switch cd
CD is UP:
if keypress is L then CD is LEFT
else if keypress is R then CD is RIGHT
else if keypress is D then CD is DOWN
else if keypress is U then call your Move(UP) function and make the move.
CD is RIGHT
if keypress is L then CD is UP
else if keypress is R then call Move(RIGHT) and make the move
else if keypress is D then CD is DOWN
else if keypress is U then CD is UP
etc.
After changing the CD, you may want to call a TURN(CD) function to show the robot has actually turned, on the screen with a change of direction to the robot's char.
Move() must check ahead that the robot's grid at that point (x,y), is not a wall, or a box. If it's a wall, the robot just stops, if it's a box, the robot calls PushBox(), to see if the box can be pushed one point in the grid.
Hope that gives you some helpful idea's. If you're learning C, I wouldn't get all caught up with using pointers and unions and such. Try to keep your program at your level, or just a bit more. Making a program too complicated is just the opposite of what you want to do. KISS will help with the problem solving needed.
Adak