Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Why does my code not compile on gradescope? #include #include #define SIZE 3 void printBoard ( char board [ SIZE ] [ SIZE ] )
Why does my code not compile on gradescope?
#include
#include
#define SIZE
void printBoardchar boardSIZESIZE;
int isValidInputchar input int x int y;
int isOccupiedchar boardSIZESIZE int x int y;
void drawOchar boardSIZESIZE int x int y;
int main
char boardSIZESIZE;
char input;
int turn ; for X for O
int x y;
while
printBoardboard;
if turn
printfxs turn ;
else
printfos turn ;
if fgetsinput sizeofinput stdin NULL
printf
;
break;
if isValidInputinput &x &y
continue;
x ; Adjust for based index
y ; Adjust for based index
if isOccupiedboard x y
continue;
if turn
boardxyX;
else
drawOboard x y;
turn;
if turn
break;
printBoardboard;
return ;
void printBoardchar boardSIZESIZE
int i j;
for i ; i SIZE; i
for j ; j SIZE; j
printfc boardij;
if j SIZE printf;
printf
;
if i SIZE printf
;
int isValidInputchar input int x int y
int n sscanfinputdd x y;
if n
fprintfstderr "Need coordinates
;
return ;
if n
fprintfstderr "Illegal character in input s
input;
return ;
if x x y y
fprintfstderrdd is not a valid square; the numbers must be between and inclusive
xy;
return ;
return ;
int isOccupiedchar boardSIZESIZE int x int y
if boardxy
fprintfstderrc has played dd
boardxy x y ;
return ;
return ;
void drawOchar boardSIZESIZE int x int y
boardxyO;
PROBLEM: Enhance the tictactoe game so people can play. To do this, you need to add anO that, like the X is drawn in the square. Then prompt the user for a square identifier, and alternate between drawing Xs and Os at those locations on the board. The first move is for X You need to detect and reject when a user plays a square that is already taken. Stop after the board is full that is plays You do not have to worry about who wins.
The O is to be times centered in the middle of the square.
Here are the messages your program should print to the standard output:
The tictactoe board, with Xs and Os as appropriate;
When it is Xs turn, print Xs turn note the space after the ; and
When it is Os turn, print Os turn again note the space after the
Here are the error messages; all are to be printed on the standard error:
When the user enters only coordinate: Need coordinates
the
is a newline;
When there is an illegal character in the input: Illegal character in input c
the c is to print the offending character; and
When the square is already occupied: c has played dd
where c is either X or O whichever is already in the square, and dd are the coordinates of the occupied square; and
When an invalid set of coordinates are entered: dd is not a valid square; the numbers must be between and inclusive
each d is one of the invalid numbers
If the program reads an end of file at the prompt, print a newline and quit.
The program should exit with an exit status code of
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started