Hi--I'm trying to implement Conway's Game of Life on a 10x10 board (with borders), and I'm having a bit of trouble. At this point, it seems most likely that said trouble lies in either my display function or the for loop I use to call it in main, so here's the code in question:
Code:
void display_life(char life[12][12]){
int row, column, status;
char enter;
printf("\n\n");
for(row=0; row<=11; row++){
for(column=0; column<=11; column++){
printf("%c", life[row][column]);
if(column==11){
printf("\n");
}//if column==11
}//for column
}//for row
do{
printf("\nPress the Enter key to continue.");
status=scanf("%c", &enter);
}while(status!=1);
} //displays the life board and waits for the user to press the Enter key.
int main(){
char life[12][12];
int count, status;
init_life(life);
display_life(life);
for(count=1; count<9; count++){
update_life(life);
}//for(count=0; count<10; count++)*/
return 0;
}//main
Now, as far as I can tell, display_life should wait for the user to press return before main moves on to the for loop, but this is the output I get on running the program:
Code:
teyla:~ quasigreat$ ~quasigreat/a.out
Please enter the file name>> Life1.dat
|__________|
|XXXXXXXXXX|
| |
|XXXXXXXXXX|
|XXXXXXXXXX|
| |
|XXXXXXXXXX|
|XXXXXXXXXX|
|XXXXXXXXXX|
| |
|XXXXXXXXXX|
|__________|
Press the Enter key to continue.
|__________|
|X |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|__________|
Press the Enter key to continue.
To clarify, it displays the second board without waiting for keyboard input. Any help would be much appreciated. (I might even offer to sacrifice my firstborn. You never know.)