As the compiler says, grid
was not declared in the scope of your function :) "Scope" basically means a set of curly braces. Every variable is limited to the scope in which it is declared (it cannot be accessed outside that scope). In your case, you're declaring the grid
variable in your main()
function and trying to use it in nonrecursivecountcells()
. You seem to be passing it as the argument colors
however, so I suggest you just rename your uses of grid
in nonrecursivecountcells()
to colors
. I think there may be something wrong with trying to pass the array that way, too, so you should probably investigate passing it as a pointer (unless someone else says something to the contrary).