Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a C programing code Tic-tac-toe (or noughts and crosses) is a popular children's game that is easy to learn and play (see https://en.wikipedia.org/wiki/Tic-tac-toe).

Please write a C programing code

image text in transcribed

image text in transcribed

Tic-tac-toe (or "noughts and crosses") is a popular children's game that is easy to learn and play (see https://en.wikipedia.org/wiki/Tic-tac-toe). For this lab you are to implement a simple module (i.e. you will write implementation file ttt.c) that allows you to represent and place marks on a tic-tac-toe board. Here is the specification file ttt.h (available on the class Canvas pages); #ifndef TTT_H #define TTT_H #define EMPTY typedef struct btype *board; /* assume that the upper left corner of the board is square 1,1 all functions are undefined when passed an illegal row,col */ board createBoard(); // returns an empty board (all squares set to EMPTY) void putX(board b, int row, int col); // puts an 'X' at row,col void puto (board b,int row, int col); // puts an 'O' at row,col char get(board b, int row, int col); // returns value at row, col char *toString(board b); // returns a string representation of board b; // string returned does not have to be the minimum // size to store the board. See sample run for format. #endif Here is a sample driver file tttDriver.c (also on the Canvas class pages) that you can use to test your code: #include #include "ttt.h" int main(void) { board b = createBoard(); putX(b,1,1); putX(b,2,2); put0(6,1,2); put(1,3,3); printf(" 1 I "); 1 for(int r = 1; r #include "ttt.h" int main(void) { board b = createBoard(); putX(b,1,1); putX(b,2,2); put0(6,1,2); put(1,3,3); printf(" 1 I "); 1 for(int r = 1; r

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions