I keep getting a run time error, i think i has to do with the generate and/or checkNeighbor methods

#include <iostream>
#include <vector>
#include <windows.h>
using namespace std;


void display(vector<vector<char> > grid)
{
    for(int x = 0; x < grid.size(); x++)
    {
        for(int y = 0;y < grid[x].size();y++)
        {
            cout << grid[x][y];
        }
        cout << endl;
    }
}


void check_neighbors(vector<vector<char> > world, int neighborArray[21][79])
{
    for(int i = 0;i < world.size();i++)
    {


        for(int j = 0;world[i].size();j++)
        {
            int neighbors = 0;
            if(world[i][j] == '*')
            {

                if(world[i+1][j+1]=='*')
                {
                    neighbors +=1;
                }
                if(world[i][j-1]=='*')
                {
                    neighbors +=1;
                }
                if(world[i+1][j-1]=='*')
                {
                    neighbors +=1;
                }
                if(world[i-1][j]=='*')
                {
                    neighbors +=1;
                }
                if(world[i-1][j+1]=='*')
                {
                    neighbors +=1;
                }
                if(world[i][j+1]=='*')
                {
                    neighbors +=1;
                }
                if(world[i+1][j-2]=='*')
                {
                    neighbors +=1;
                }
                if(world[i+1][j]=='*')
                {
                    neighbors +=1;
                }

                neighborArray[i][j] = neighbors;

            }
        }
    }
}


void generation(vector<vector<char> > env, int neighborArr[21][79])
{
    for(int i = 0;i < env.size();i++)
    {
        for(int j = 0;env[i].size();j++)
        {
            if(env[i][j] == '*')
            {
               if(neighborArr[i][j] < 2)
               {
                   env[i][j] = '.';
               }
               if(neighborArr[i][j] > 3)
               {
                   env[i][j] = '.';
               }
            }
            else
            {
                if(neighborArr[i][j] = 3)
                {
                    env[i][j] = '*';
                }
            }
        }
    }
}

int main()
{
	vector<vector<char> > world(79, vector<char>(21, '.'));
	int neighborArray[21][79];

	//Intial condiion
	world[1][1] = '*';
	world[1][2] = '*';
	world[2][2] = '*';
	world[1][5] = '*';
	world[3][4] = '*';
	world[3][5] = '*';
	world[3][6] = '*';
    for(int c = 0; c < 10;c++)
    {
	check_neighbors(world, neighborArray);

	generation(world, neighborArray);
    Sleep(1000);
	display(world);
    }
	return 0;
}

Post the error that you are getting

When i run the .exe, the terminal opens for about 2 secs does nothing windows says it has stopped working

My guess would be a seg fault. Check your array indexes. In particular, check line 26. Make sure it's what you intend.

for(int j = 0;world[i].size();j++)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.