I am writing this program and one of the functions is ifValid().
So ifValid is supposed to tell me whether there are too many X's or O's on a tic tac toe board. When i run the program it works, except for then it continues into the next function and then adds those print lines too.
How can I end this function if ifValid finds that the board is invalid?
Here is the code for this function:
Code:bool ifValid(int topL, int topC, int topR, int cenL, int cenC, int cenR, int botL, int botC, int botR) { bool success = false; int total = 0; if (topL == 'X') total++; if (topC == 'X') total++; if (topR == 'X') total++; if (cenL == 'X') total++; if (cenC == 'X') total++; if (cenR == 'X') total++; if (botL == 'X') total++; if (botC == 'X') total++; if (botR == 'X') total++; if (total > 5) { printf("Invalid Board. There are too many X's.\n"); } else if(total <= 3) { printf("Invalid Board. There are too many O's.\n"); } (!success); return success; }



LinkBack URL
About LinkBacks


