im working on an assignment in C to hhandle Conway's game of life. This is basically a cellular simulation. It involves handling two dimensional arrays (i won't go into the details because that's not really important for the problem im having). Now according to the assignment specifications, there is a function (called life_invert) which must return the two dimensional array/matrix using the functions return mechanism and not using structs or pass-by-references.
This is what I've done so far:
the function for inverting is basicall as follows:
//CELL is defined previously as a char
//EP100_CELL_MAX_Y and .._X are previously defined as 512
CELL (**life_invert(CELL old_pattern[EP100_CELL_MAX_X][EP100_CELL_MAX_Y]))
static CELL new_pattern[EP100_CELL_MAX_X][EP100_CELL_MAX_Y];
// Some of my processing on array new_pattern
return (CELL **)new_pattern;
my mainline has two arrays declared like the static one above (but non-static) called 'old' and 'new'
in the mainline i try to get the new one by doing:
new = life_invert(old);
This results in the error:
error, incompatible types in assignment.
i've even tried:
**new = life_invert(old)
//same error as before
i've tried doing the function declaration as:
CELL (*life_invert(CELL old_pattern[EP100_CELL_MAX_X][EP100_CELL_MAX_Y]))
that comes up with errors about "life_invert declared as function which returns an array"
im quite confused about this because everything else works fine. I did it with the array within a struct and it was fine, i did it with the array as a second parameter and it worked fine, but according to the specifications, it must use the function return mechanism to return the array.
Does anyway know why this error is occuring? I can't seem to see where i've gone wrong here as far as logic and syntax is concerned but then again, im not yet a pro at C.
Can somebody please explain to me what i shud be doing or point me in the ryt direction?