I am new to C programs. I have tried to write the code for game of life. I started with just the first part. But its still not done. There are some errors. could you please point out where I am wrong?
#include<stdio.h>
#include<stdio.h>
#define NUM_ROWS 100
#define NUM_COLS 100
int game_of_life(int h[][NUM_COLS], int row, int col);
int main()
{
int a[NUM_ROWS][NUM_COLS] = { {0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 1, 0, 0},
{0, 1, 0, 1, 0, 1, 0},
{0, 0, 1, 0, 1, 0, 0},
{0, 1, 0, 1, 0, 1, 0},
{0, 0, 1, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0} };
int num_rows= 7;
int num_cols = 7;
int life_test;
life_test = game_of_life(a, num_rows, num_cols);
printf ("%d", &life_test);
return 0;
}
int game_of_life(int h[][NUM_COLS], int row, int col)
{
int i, j;
int a=0;
for( i = 2; i < row; i++)
for( j = 2; j < col; j++)
if (h[i][j-1]=0)
a++;
else
if (h[i-1][j-1] =0)
a++;
else
if(h[i-1][j] = 0)
a++;
else
if (h[i-1][j+1]) = 0
a++;
if (a=3)
h[i][j]= 1;
else
h[i][j]=0;
return h[i][j];
}
Thanks!