Solution for Exercise 12-22
ex1222
#include <stdio.h> int main() { char tictactoe[3][3] = { '.', '.', '.', '.', 'X', '.', '.', '.', '.' }; int x,y; /* display game board */ puts("Ready to play Tic-Tac-Toe?"); for(x=0;x<3;x++) { for(y=0;y<3;y++) printf("%c\t",tictactoe[x][y]); putchar('\n'); } return(0); }
Notes
* This code illustrates one of those times where it's easier to declare an initialized array than to construct code that fills the array. For a larger array, such as a chessboard, I would still initialized it using code, albeit in a function.
* Code::Blocks may throw a "missing braces" warning at you. That's okay. Code::Blocks activates all warnings for your C code, including one called -Wmissing-braces. The braces are included in the code, so you can freely ignore the warning. (This is a great example of a compiler warning you don't heed.)
Copyright © 1997-2024 by QPBC.
All rights reserved