Tic Tac Toe

I am trying to make a tic tac toe game.
I get the following error:

error C2664: 'Move' : cannot convert parameter 1 from 'char [3][3]' to 'char'
1> There is no context in which this conversion is possible

My idea of the game is the following:
- using a 2D array to draw the board
- making a move by overwriting the 2D array

I need some help because I am stuck.
Thanks!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <iostream>
#include <conio.h>
#include <string>

using namespace std;

void DrawBoard();
int Move(char, int);

int main()
{
	int move;
	char board[3][3];


	DrawBoard();  //Function that draws the board;

	cout << "Enter number to make a move:";
	cin >> move;

	Move(board, move);

	_getch();
}

void DrawBoard()
{
	int i, j;
	char board[3][3] = 
	{{'1', '2', '3'}, 
	{'4', '5', '6'}, 
	{'7', '8', '9'}};


	for(i=0; i<3; i++){
		for(j=0; j<3; j++)
			cout << board[i][j] << " ";
			cout <<endl;
	}
	
		
			
}

int Move(char board[3][3], int move)
{
	while(cin)
	{
		cin >> move;
		
			switch(move)
			{
			case 1:
				board[0][0]= 'X';
				break;
			
			case 2:
				board[0][1]= 'X';
				break;
			
			case 3:
				board[0][2]= 'X';
				break;
			
			case 4:
				board[1][0]= 'X';
				break;
			
			case 5:
				board[1][1]= 'X';
				break;
			
			case 6:
				board[1][2]= 'X';
				break;
			
			case 7:
				board[2][0]= 'X';
				break;
			
			case 8:
				board[2][1]= 'X';
				break;
			
			case 9:
				board[2][2]= 'X';
				break;

			default:
				cout <<"Invalid move!";
				return 0;
			}
	}		
}
Last edited on
Line 8. Your forward declaration doesn't match the function you're trying to call.
I know that, but how can I write the function in order to work properly?
Make the forward declaration match the function you're trying to call.

i.e. change line 8 to int Move(char[3][3], int);
Thank you for your answers, I still need some help, but my code has become very long something near 1000 lines...so where should I post?
If you have a specific problem with the code, write the shortest code you can that replicates the problem and post that.

Or you could post the code in a web paste utility like http://pastebin.com/
line 13: board is uninitialized.

line 26: DrawBoard is always going to display the numbers 1-9. It's not going to display the current status of the board.

line 47: You're going to loop forever accepting input from the user. You never display the updated board. How is the user going to know where to move?
Topic archived. No new replies allowed.