I am making a "Game of Life" program in .C and need to set my entire 2D array, for if the organism in that spot is alive (represented by a boolean), to a 2D array of the calculated next generation. I realize there may be an easier way to make organism[][] = nextGeneration[][], but there are several different functions where I need to be able to pass the 2D array and alter it. A few other functions where I need to be able to access the array are: resetting all variables, translating an input file to my array, calculating the next generation, and printing the array out to the console to display. I found some information online about needing to pass a separate integer to hold the size of my array, but I don't understand how I'm supposed to pass the entire array so I can edit it and return the whole change. (Note: I don't actually need to return anything, because the array should already be passed as a pointer. There may be flaws in my logic here..)
I would be grateful if anyone could point me in the right direction!
Would it be easier for me to code my nested loop inside my main() then call organism[j][m] as a single boolean value? Then call the function for every iteration? Or would this cause unnecessary memory usage? (For all I know it could use less memory..)
The reason I am trying to leave it in a function is because it is a group project and other people are working on the functions. I just need to figure out how to pass the appropriate parameters before they can start.
My array is declared using constants, so the array will not need to be dynamic. Thank you though!
So all I need to worry about is passing the second array size(columns), then passing the first(rows) as an int?
void spanGeneration(bool organism[][width], int height)
And this calls my same exact array from my earlier code in main? Seems strange cause it should either need to know the entire size, or it should be ambiguous so it can refer to the array it's trying to access.
can I not do something like:
void spanGeneration(bool organism[height][width])
Or will this only call one exact point in that array?
I'm still having an issue...
It says that there is a syntax error: ')'
It says there is this error for every line in my header defining functions with arguments using my two arrays, but does not say where this fabled ')' goes. I keep trying to put it random places and seeing if it works, but I have no idea why it thinks it needs an ending parentheses, but it also say's the ending parentheses need to be in my library several times at the beginning of each function.