Hello everybody
I am doing the project about Game Of Life. Professor require that there shuold be a function create a menu, a function display the array, a function for testing. So far I'm done the menu and display. I can display the initial array now. But when I cout the initial array again in the main function, there are weird symbols pop up on screen and that may be the reason I cannot count the neighbors. When I cout the neighbors, there are only zero numbers.
int main()
{
char gen[NROWS][NCOLS];
int ini,i,j;
cout<<"Plese enter the ini: "<<endl;
cin>>ini;
Menu(gen, ini); //I can get the array right here
for(i=0;i<NROWS;i++)
{
for(j=0;j<NCOLS;j++)
{
cout<<gen[i][j]<<" ";//But when I cout again, the weird symbols appear
}cout<<endl;
}
//Neighbor_Count(gen);//I can't count the neighbor.
system("pause");
return 0;
}
One problem I see is, you've declared gen[][] to be char, but you're filling it with int's. char gen[NROWS][NCOLS]; // Don't see where NROWS or NCOLS, is initiated
1 2 3 4 5 6 7
if(ini == 1)
{
gen[5][5] = 1; // Try using '1' on these
gen[5][6] = 1;
gen[5][7] = 1;
Display(gen);
}
For better help, maybe show the code for the whole program. Easier to see where errors may be lurking.