Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Purpose: Use of two dimensional CHARACTER arrays and for loops Passing arrays between functions Description Implement a C program using functions and arrays. Ask user

Purpose:

Use of two dimensional CHARACTER arrays and for loops

Passing arrays between functions

Description

Implement a C program using functions and arrays. Ask user for a row / column for a tic/tac/toe game. Check if the row/column is valid using checkError( int, int ). This function takes two integers as input argument and returns an integer. It returns 1 if the row/column is valid otherwise it will return a 0. Use a loop to continue to ask for an input until the user enters a good row/column. Prototype: int checkError(int, int, char [ ] [ ]);

setGame this function will take the two dimensional character array and put a - in every location to set up the game. Prototype: void setGame(char [ ] [ ]);

Next function to implement is:

printGame Takes in a two dimensional array that represents the tic tac toe game board. Displays the current game board state as shown in the sample output below.

Prototype: void printGame(char [ ] [ ]);

Make sure you pay attention to prototypes, function calls and function definitions. Not writing in the form of function prototypes will result in loss of credit in the labs. You will use functions like these in the lab next week.

Check the Sample output before you start.

Sample Output

Characters in bold are input from the user

$ ./a.out

Welcome to the game!

1 2 3

1 - - -

2 - - -

3 - - -

Enter a row and column to place your X in (0 0 to quit): 1 2

1 2 3

1 - X -

2 - - -

3 - - -

Enter a row and column to place your O in (0 0 to quit): 1 2

Sorry, that spot is not valid. Try again: 3 1

1 2 3

1 - X -

2 - - -

3 O - -

Enter a row and column to place your X in (0 0 to quit): 3 3

1 2 3

1 - X -

2 - - -

3 O - X

Enter a row and column to place your O in (0 0 to quit): 2 2

1 2 3

1 - X -

2 - O -

3 O - X

Enter a row and column to place your X in (0 0 to quit): 3 4

Sorry, that spot is not valid. Try again: 3 1

Sorry, that spot is not valid. Try again: 1 3

1 2 3

1 - X X

2 - O -

3 O - X

Enter a row and column to place your X in (0 0 to quit): 0 0

Game over!

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_2

Step: 3

blur-text-image_3

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students explore these related Databases questions

Question

What your favourite topic in mathematics?

Answered: 3 weeks ago