I'm not sure what you mean with this. Just loop through the complete matrix and print the value.
Here's a small example that works on my system:
Code:
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define MAX_ROW 10
#define MAX_COL 10
#define EMPTY 0
#define GOAL 1
int matrix[MAX_ROW][MAX_COL];
void show(int Row, int Col)
{
system("cls"); // works for me, not on all systems
for(int r = 0; r < MAX_ROW; r++)
{
for(int c = 0; c < MAX_COL; c++)
{
if(c == Col && r == Row)
cout << "[*]";
else if(matrix[r][c] == GOAL)
cout << "[$]";
else
cout << "[ ]";
}
cout<< endl;
}
}
int move(int *Row, int *Col)
{
char direction;
cout << "Which way? (N, E, S, W) :";
cin >> direction;
switch(toupper(direction))
{
case 'N': if(*Row > 0) *Row--; break;
case 'E': if(*Col > 0) *Col--; break;
case 'S': if(*Row < MAX_ROW-1) *Row++; break;
case 'W': if(*Col < MAX_COL-1) *Col++; break;
case 'Q': return -1;
}
return 0;
}
int main(void)
{
int Row = 0;
int Col = 0;
// Initialize board with zero's
//for(int i = 0; i < MAX_ROW; i++)
// for(int j = 0; j < MAX_COL; j++)
// matrix[i][j] = 0;
memset(&matrix, EMPTY, MAX_ROW * MAX_COL * sizeof(int));
srand(time(NULL));
matrix[rand()%MAX_ROW][rand()%MAX_COL] = GOAL;
show_board(Row, Col);
while(matrix[Row][Col] != GOAL)
{
if(move(&Row, &Col) == -1)
return -1;
show(Row, Col);
}
cout << "Congratulations! You have found the legendary Golden Thingy!!!!!!!!" << endl;
getchar();
return 0;
}