tic tac toe

to start with i want to thank you for the help that you have given me already, also to let you know that i am trying to solve these problems for a good while before i post on here but im new to this and im still learning so i appologise, but im trying to write a tic tac toe program and initate a board but its giving me a very wierd error. im just wondering if im doing it correctly or completely wrong?

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
#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

int display_grid(int* board[]);

int _tmain(int argc, _TCHAR* argv[])
{
	int board[9];
	struct score{
		int player;
		int computer;
	} score;



	for(int x=0; x<9; x++)
	{
		board[x] = x+1;
	}


	display_grid(board);





	return 0;
}

int display_gird(int* board[])
{
	cout << " " << board[1] << " | " << board[2] << " | " << board[3] << endl;
	cout << "---|---|---" << endl;
	cout << " " << board[4] << " | " << board[5] << " | " << board[6] << endl;
	cout << "---|---|---" << endl;
	cout << " " << board[7] << " | " << board[8] << " | " << board[9] << endl; 

	return 0;

}


the error im getting is
1>Tic Tac Toe.obj : error LNK2019: unresolved external symbol "int __cdecl display_grid(int * const)" (?display_grid@@YAHQAH@Z) referenced in function _wmain
1>c:\users\james\documents\visual studio 2010\Projects\Tic Tac Toe\Debug\Tic Tac Toe.exe : fatal error LNK1120: 1 unresolved externals


which i have no idea what that means lol


thank you in advance
Hi,

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
void display_grid(int *board);

int main(int argc, char* argv[])
{
	int board[9];
	struct score{
		int player;
		int computer;
	} score;

	for(int x=0; x<9; x++)
	{
		board[x] = x+1;
	}
	display_grid(board);

	return 0;
}


 void display_grid(int *board)
{
	cout << " " << board[0] << " | " << board[1] << " | " << board[2] << endl;
	cout << "---|---|---" << endl;
	cout << " " << board[3] << " | " << board[4] << " | " << board[5] << endl;
	cout << "---|---|---" << endl;
	cout << " " << board[6] << " | " << board[7] << " | " << board[8] << endl; 

}


conversion requires reinterpret_cast, C-style cast or function-style cast
Last edited on
but im not changing anything? im just using the array in a function? or do i have to convert that
your function is
int display_grid(int* board[]);



The way the function call.

display_grid(board);



results:

cannot convert parameter 1 from 'int [9]' to 'int *[]'



I changed it >
void display_grid(int *board)
in the fashion
Last edited on
Topic archived. No new replies allowed.