![]() It makes adding the braces have very little influence on code length.Keep kids engaged with fun and simple games that only require paper and pencil (or a couple colored pens). That's one of the main reason I personally really like the "opening brace on the if line" coding convention. I find it just too easy to accidentally make a mistake when refactoring code that does not use braces for single-statement ifs. What would happen if you wanted to change the x and o to the upper-case letters? That refactor would require multiple changes around the code, and be error-prone. ![]() Most of your constants should de defined as global variables or defines. You should really consider changing that whole approach.Ī simple "enum and switch"-based state machine would work just as well, and be a lot more straightforward. Gotos make code really hard to follow, and difficult to refactor. Printf("\nPlease input where you want to place O: ") Ĭhecker = PositionCalculation(board, selection, 'o') Īvoid using goto unless absolutely necessary If (HorizontalCheck(board) = true || VerticalCheck(board) = true || DiagonalCheck(board) = true) Printf("Invalid input, please try again: ") Ĭhecker = PositionCalculation(board, selection, 'x') Initializing the Board void BoardInitializer(char board) Would appreciate if anyone could look through my tic tac toe code and what I possibly do to improve upon it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |