Code:

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <Windows.h>
const int s = 25;
typedef char GRID[s][s];
void turnOn(GRID g, int x, int y);
void turnOff(GRID g, int x, int y);
bool lh2o3(GRID g, int x, int y);
bool dhe3(GRID g, int x, int y);
int gridCheck(GRID g, int x, int y);
void printGrid(GRID g);
void initGrid(GRID g);
void copyGrid(GRID dest, GRID src);
int main(){
GRID grid, nextGrid;
initGrid(grid);
turnOn(grid, 10,15);
turnOn(grid, 10,16);
turnOn(grid, 9,15);
turnOn(grid, 11,15);
turnOn(grid, 10,14);
//Game
while (true){
printGrid(grid);
initGrid(nextGrid);
for(int x=0;x<s;++x){
for(int y=0;y<s;++y){
if((grid[x][y] == '0') and (lh2o3(grid, x, y) == true)){
turnOn(nextGrid, x, y);
}
else if((grid[x][y] == '-') and (dhe3(grid, x, y) == true)){
turnOn(nextGrid, x, y);
} else {
turnOff(nextGrid, x, y);
}
}
}
copyGrid(nextGrid, grid);
system("PAUSE");
system("CLS");
}
}
// Activate cell
void turnOn(GRID g, int x, int y){
g[x][y] = '0';
}
// Kill cell
void turnOff(GRID g, int x, int y){
g[x][y] = '-';
}
// Check whether living cell has two or three neighbours
bool lh2o3(GRID g, int x, int y){
if(gridCheck(g, x, y) == 2 or gridCheck(g, x, y) == 3){
return true;
} else {
return false;
}
}
// Check whether dead cell has exactly three neighbours
bool dhe3(GRID g, int x, int y){
if(gridCheck(g, x, y) == 3){
return true;
} else {
return false;
}
}
// Scan adjacent cells for life
int gridCheck(GRID g, int x, int y){
int count = 0;
//To avoid array underrun and overrun
if (x > 0 && g[x-1][y] == '0') ++count;
if (x < s-1 && g[x+1][y] == '0') ++count;
if ( y > 0 && g[x] [y-1] == '0') ++count;
if ( y < s-1 && g[x] [y+1] == '0') ++count;
if (x > 0 && y > 0 && g[x-1][y-1] == '0') ++count;
if (x > 0 && y < s-1 && g[x-1][y+1] == '0') ++count;
if (x < s-1 && y > 0 && g[x+1][y-1] == '0') ++count;
if (x < s-1 && y < s-1 && g[x+1][y+1] == '0') ++count;
return count;
}
void printGrid(GRID g){
for(int x=0;x<s;++x){
for(int y=0;y<s;++y){
std::cout << g[x][y] << " ";
}
std::cout << std::endl;
}
}
void initGrid(GRID g) {
memset(g, '-', s * s);
}
void copyGrid(GRID dest, GRID src) {
memcpy(dest, src, s * s);
}