my implementation of conway's game of life in C++ I found Conway's game of life. I had heard of it, of course, but didn't think it would be so easy and fun to implement. Anyway, here's my code which I know needs a lot of polish:
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;windows.h&gt;

#define SIZE 10

using std::vector;

struct Pos {
    int x;
    int y;

    Pos(int ix, int iy) : x(ix), y(iy) {}
};

void printGrid();

int getNeighborCount(Pos cellPos);

void next(int (&amp;universe)[SIZE][SIZE]);

void killOrBirthCells(int (&amp;universe)[SIZE][SIZE], vector&lt;Pos&gt; &amp;toKill, vector&lt;Pos&gt; &amp;toBirth);

void cellFate(int &amp;cell, Pos cellPos, int neighborCount, vector&lt;Pos&gt; &amp;toKill, vector&lt;Pos&gt; &amp;toBirth);

void printUniverse(int (&amp;universe)[SIZE][SIZE]);

int main() {
    int universe[SIZE][SIZE] = {0};
    
    // glider 
    universe[0][2] = 1;
    universe[1][2] = 1;
    universe[2][2] = 1;
    universe[2][1] = 1;
    universe[1][0] = 1;

    while (1) {
        system(&quot;cls&quot;);
        next(universe);
        printUniverse(universe);
        Sleep(500);
    }

    return 0;
}

int getNeighborCount(int (&amp;universe)[SIZE][SIZE], Pos cellPos) {
    int count = 0;
    for (int i = 0; i &lt; 3; i++) {
        for (int j = 0; j &lt; 3; j++) {
            int x = cellPos.x - 1 + j;
            int y = cellPos.y - 1 + i;
            // handle cells on the edge
            if (x &gt;= 0 &amp;&amp; y &gt;= 0 &amp;&amp; x &lt; SIZE &amp;&amp; y &lt; SIZE
                &amp;&amp; universe[cellPos.y - 1 + i][cellPos.x - 1 + j] == 1) {
                count++;
            }
        }
    }
    // exclude itself
    if (universe[cellPos.y][cellPos.x]) {
        return count - 1;
    }
    return count;
}

void next(int (&amp;universe)[SIZE][SIZE]) {
    std::vector&lt;Pos&gt; toKill;
    std::vector&lt;Pos&gt; toBirth;
    
    for (int i = 0; i &lt; SIZE; i++) {
        for (int j = 0; j &lt; SIZE; j++) {
            Pos cellPos{j, i};
            int neighborCount = getNeighborCount(universe, cellPos);
            cellFate(universe[i][j], cellPos, neighborCount, toKill, toBirth);
        }
    }
    
    killOrBirthCells(universe, toKill, toBirth);
}

// populate toKill and toBirth vectors
void cellFate(int &amp;cell, Pos cellPos, int neighborCount, vector&lt;Pos&gt; &amp;toKill, vector&lt;Pos&gt; &amp;toBirth) {   
    if (cell == 1) {
        // lonely
        if (neighborCount == 0 || neighborCount == 1) {
            toKill.push_back(cellPos);
        // overcrowded
        } else if (neighborCount &gt;= 4 &amp;&amp; neighborCount &lt;= 8) {
            toKill.push_back(cellPos);
        }
    } else {
        if (neighborCount == 3) {
            toBirth.push_back(cellPos);
        }
    }
}

void killOrBirthCells(int (&amp;universe)[SIZE][SIZE], vector&lt;Pos&gt; &amp;toKill, vector&lt;Pos&gt; &amp;toBirth) {
    for (Pos cellPos : toKill) {
        universe[cellPos.y][cellPos.x] = 0;
    }
    for (Pos cellPos : toBirth) {
        universe[cellPos.y][cellPos.x] = 1;
    }
    toKill.clear();
    toBirth.clear();
}

void printUniverse(int (&amp;universe)[SIZE][SIZE]) {
    for (int i = 0; i &lt; SIZE; i++) {
        for (int j = 0; j &lt; SIZE; j++) {
            if (universe[i][j] == 1) {
                std::cout &lt;&lt; 'x'; 
            } else {
                std::cout &lt;&lt; '.'; 
            }
        }
        std::cout &lt;&lt; '\n';
    }
}
If you're going to use C++, make full use of the language. Create a class to hold your universe, then all of your non-main functions can be members. You also won't have to pass around a reference to the universe array as it would be a member of the class.
One alternative to the toKill and toBirth vectors is to have two &quot;universe&quot; arrays. You'd use one as the source, and copy over and update the values into the second, then trade off which array you modify on the next pass thru. cellFate would return the new (updated) value for that cell, and killOrBirthCells would be eliminated.
getNeighborCount is only using i and j as offsets to the x and y values. You can redo the loops to directly update the x and y values, and also handle the edge clipping by proper tracking of the start and end values for the loops. It would also be easy to exclude the cell itself.
Combining all that we get a new getNeighborCount (that would be a member of a class):
int Universe::getNeighborCount(Pos cellPos) const {
    int count = 0;
    int sx = std::max(cellPos.x - 1, 0);
    int ex = std::min(cellPos.x + 1, SIZE - 1);
    int sy = std::max(cellPos.y - 1, 0);
    int ey - std::min(cellPos.y + 1, SIZE - 1);
    for (int y = sy; y &lt;= ey; ++y) {
        for (int x = sx; x &lt;= ex; ++x) {
            if (y != cellPos.y || x != cellPos.x) {
                if (universe[y][x] == 1)
                    count++;
            }
        }
    }
    return count;
}

You may be able to reduce flickering by moving the system(&quot;cls&quot;); call to immediately before the call to printUniverse. This would reduce the amount of time that you have an empty screen.