// Mr. Minich
// CMPSC 201
// August 23, 2000
// Ch. 11 Demo Program #1
// Purpose - to illustrate passing a two-dimensional array of chars by reference
#include <iostream>
using namespace std;
void move(char formalMatrix[3][3]); // places x on the tic tac toe board
// arrays are passed by simulated reference (aka address) even though the
// address-of operator (&) isn't used in the parameter list
int main()
{
char matrix[3][3]; // 3 by 3 tic tac board
int row; // row of tic tac toe board
int col; // column of tic tac toe board
for(row = 0; row < 3; row++) // assigning X's to all positions
{
for(col = 0; col < 3; col++)
{
matrix[row][col] = 'X';
}
}
move(matrix); // placing 0 in middle
//********* displaying tic tac toe board ***********
for (row = 0; row < 3; row++)
{
for(col = 0; col < 3; col++)
{
cout << matrix [row][col] << ' '; // printing each row
}
cout << endl; // wrapping to next row
}
cout << endl << endl;
return 0;
}// end of main
void move(char formalMatrix[3][3])
{
formalMatrix[1][1] = 'O'; // assigning 0 to middle square of board
// since matrix was passed by simulated reference (or address)
// this assignment affects the passed argument (matrix) in the
// main function
}// end of move