## Game of Life program

Hi, I'm fairly new to programming and have been given this assignment:
Conway's Game of Life usesthese rules:
-Each cell is either alive or dead
-Cells are represented on a rectangular grid, each cell has 8 neighboring spaces
-A live cell with fewer than 2 or more than 3 live neighbors dies on the next iteration
-A dead cell with exactly 3 live neighbors becomes alive on the next iteration
-Otherwise the cell's state is unchanged on the next iteration

Your task is to write a C++ program that runs the game on a grid that is 24 rows by 79 columns. The easiest way to do this is to maintain two two-dimensional arrays of int, one for the current state, one for the next state. Represent live cells with a 1, dead cells with a 0. Pass them to a function that calculates the next state from the current one, and alternate the order of the arguments on each call. Clear the screen, display the state array (space for dead, X for alive), pause for a short time, then repeat.
My teacher gave us the main function and the function called neighbors, but we need to write the other functions listed in the header. Here's what I have so far:

Code:
int main(int argc, char** argv)
{
ifstream fin;
string fileName = "";
if (argc > 1)
fin.open(argv[1]);
else
{
cerr << "Name of input file? ";
cin >> fileName;
fin.open(fileName.c_str());
}
if (!fin)
{
if (fileName == "")
perror(argv[1]);
else
perror(fileName.c_str());
exit(1);
}
int current[ROWS][COLUMNS] = {0};
int next[ROWS][COLUMNS] = {0};
int r, c;
while (fin >> r >> c)
{
current[r][c] = 1;
}
while(!equal(current, next))
{
print(current);
nextstate(current, next);
print(next);
nextstate(next,current);
}
}

bool equal(int current[ROWS][COLUMNS], int next[ROWS][COLUMNS])
{
int magicNumber = (24 * 79);
int count =0;
bool same = false;

for (int r=0; r<ROWS; r++)
{
for (int c=0; c<COLUMNS; c++)
{
if (current[r][c] == next[ROWS][COLUMNS])
count++;
}
}
if (count == magicNumber)
same = true;
else
same = false;
return(same);
}

void print(int current[ROWS][COLUMNS])
{
system("cls");
for (int r=0; r<ROWS; r++)
{
for (int c=0; c<COLUMNS; c++)
{
if (current[r][c] == 1)
cout << "X";
else
cout << ".";
}
cout << endl;
}
Sleep(500);
}

void nextstate(int current[ROWS][COLUMNS], int next[ROWS][COLUMNS])
{
int sum;
for (int r=0; r<ROWS; r++)
{
for (int c=0; c<COLUMNS; c++)
{
sum = neighbors(current, r, c);
if(current[r][c] == 1)
{
if (sum < 2 || sum > 3)
next[r][c] = 0;
else
next[r][c] = 1;
}
else
{
if (sum == 3)
next[r][c] = 1;
else
next[r][c] = 0;
}

}

}
}

//*******************************************************************
//  Return number of neighbors of cell current[i][j]
int neighbors(int current[ROWS][COLUMNS], int i, int j)
{
int r, c;
int sum = 0;
for (r = i-1; r<=i+1; r++)
{
for (c = j-1; c<=j+1; c++)
{
if ((r >= 0) && (r < ROWS) && (c >=0) && (c<COLUMNS))
{
sum += current[r][c];
}
}
}
sum -= current[i][j];
return sum;
}
First off, I'm not even sure if I've done this correctly at all. My problem right now is that every time I run the program, I can't get it to print anything but 1s and 0s, when it's supposed to print Xs for 1s and blanks for 0s (he gave us a .exe file to see what the end product should look like, and it's various patterns formed by Xs). How can I get it to print something other than the numeric values of each cell?

Unless I'm totally off base with this assignment and have done it completely wrong. All the other codes for this program that I've found online seem much more complicated than mine, so I feel like I must have done something wrong.