I have been trying to write a code for Conways Game of life, the thing is I need to generate a matrix of char filled with the elements * or o(o marks a dead cell,*marks an alive one).
The Rules:
For a cell that is alive:
Each cell with one or no neighbors dies, as if by loneliness.
Each cell with four or more neighbors dies, as if by overpopulation.
Each cell with two or three neighbors survives.
For a dead cell:
Each cell with three neighbors becomes alive.
OK i designed a function called Generation that receives a pointer to the matrix,a number of columns and lines,and the number of generations.(the number of generations represents how many times I have to aply the rules above for the matrix.
The only way for the rules to apply simultaneously is to create another empty matrix in which I record the modifications and then pass that one.
Apparently I'm unable to create the matrix in order to store the new Information and the pass it to the function.
I only want to display the matrix for the last generation.
char** generation(char **z,int T,int n,int m)
{
if (T==0) return z;
int j,i;
char sec[1000][1000]; //here I'm tryng to create a matrix of char
for (i=1;i<=n;i++) //this where I try to initialise it
for (j=0;j<m;j++)
{sec[i][j]=z[i][j];}
for (i=1;i<=n;i++)
for (j=0;j<m;j++)
{
//the code where I apply the rules
}
z=sec;//Here is where the warning apears
return generation(z,T-1,n,m);/*I'm trying to pass the new modified matrix to the next generation*/
}
The warning I receive is: assignment from incompatible pointer type.