Code:
#include <stdio.h>
#include <conio.h>
#define WALL 1
#define NOWALL 0
void checkexits();
int map[10][10] = {1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
1 , 0 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 1 ,
1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
1 , 0 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 1 ,
1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 };
bool NORTH = true;
bool SOUTH = true;
bool EAST = true;
bool WEST = true;
struct
{
int x;
int y;
char name[10];
} PERSON = {1,1};
int main(void)
{
puts("What is your name?\n");
scanf(" %s",PERSON.name);
checkexits();
if (NORTH == true)
{printf("North ");}
if (SOUTH == true)
{printf("South ");}
if (EAST == true)
{printf("East ");}
if (WEST == true)
{printf("West ");}
getch();
return 0;
}
void checkexits()
{
if (map [PERSON.x-1][PERSON.y] == WALL)
NORTH = false;
else {true;}
if (map [PERSON.x+1][PERSON.y] == WALL)
SOUTH = false;
else {true;}
if (map [PERSON.x][PERSON.y-1] == WALL)
WEST = false;
else {true;}
if (map [PERSON.x][PERSON.y+1] == WALL)
EAST = false;
else {true;}
}