This is my final version for gameoflife. I have this error bug I can’t fix. Please help me to solve this one:
1 IntelliSense: argument of type “
int (*)[50]” is incompatible with parameter of type “int *“
line 79print(board, HEIGHT, WIDTH);
void print(int *board, int rows, int cols)
{
int x, y;
char c;
for (y = 0; y < rows; y++) {
for (x = 0; x < cols; x++) {
if (*(board + y*cols + x) == 1)
printf("X");
else
printf(" ");
}
printf("\n");
}
printf("Press any key to continue:\n");
getchar();
}
That error means you are trying to pass a function an argument of type “array of 50 pointers to int” while it should be getting an argument of type “pointer to int” (which could also be an array).
In your case, the signature of your
print()function should probably change to get anint board[][WIDTH]instead ofint *which it gets now.The change of the signature also requires a change in the function code, so the line
Should be changed to: