"Undefined reference" error in Tic-Tac-Toe

For a simple Tic-Tac-Toe game I created a function C_choose(char pin[]) to choose the moves of the computer and verify the move hasn't yet been made.
The call, parameters, prototype and usage is exactly the same as P_choose which lets the user choose his moves. And yet there is a "undefined reference" error (exact error at the end). The error stops if line 59 is commented out.
The rest of the program seems to work as expected.
Any help would be appreciated.
Thanks in advance.

Edit: Forgot to mention. I use a 11 char array called pin to store the game. Pin[1] through Pin[9] store the actual game, while Pin[0] stores the computer's sign (X or O) and Pin[10] stores the player's.

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
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <sstream>

int C_chooce(char pin[]){
	if(pin[2]==pin[3] || pin[5]==pin[9] || pin[4]==pin[7])
		return 1;
	else if(pin[1]==pin[3] || pin[5]==pin[8])
		return 2;
	else if(pin[1]==pin[2] || pin[5]==pin[7] || pin[6]==pin[9])
		return 3;
	else if(pin[1]==pin[7] || pin[5]==pin[6])
		return 4;
	else if(pin[1]==pin[9] || pin[2]==pin[8] || pin[3]==pin[7] || pin[4]==pin[6])
		return 5;
	else if(pin[3]==pin[9] || pin[4]==pin[5])
		return 6;
	else if(pin[3]==pin[5] || pin[1]==pin[4] || pin[8]==pin[9])
		return 7;
	else if(pin[7]==pin[9] || pin[2]==pin[5])
		return 8;
	else if(pin[3]==pin[6] || pin[1]==pin[5] || pin[7]==pin[8])
		return 9;
	else{
		int test=-1;
		srand(time(0));
		while(1){
			test=rand()%9+1;
			if(pin[test]!=' ')
				break;}
		return test;}
	return 0;
}

int main(){
	char pin[11], vict;
	short int where, choice=0;
	play(choice);
	while(choice!=0){
		for(int i=0;i<11;++i)
			pin[i]=' ';
		if(choice!=0){
			if(choice==1)
				info();
			s_choose(pin);
			t_out(pin);}
		while(choice!=0){
			where=P_choose(pin);
			pin[where]=pin[10];	
			t_out(pin);
			vict=v_check(pin);
			if(vict=='P' || vict=='C' || vict=='T')
				break;
			if(vict=='E'){
				std::cout<<"ERR1\n";
				break;}
			where=C_choose(pin);   //PROBLEM IS PROBABLY ABOUT HERE
			pin[where]=pin[0];
			std::cout<<"Okie doke, the computer played at "<<where<<".\n";
			t_out(pin);
			v_check(pin);
			if(vict=='P' || vict=='C' || vict=='T')
				break;
			if(vict=='E'){
				std::cout<<"ERR1\n";
				break;}
		}
		exiter(vict);
		play(choice);
	}
	std::cout<<"OK, bye-bye. Hope to see you again soon.\n";
}



owner@NetBook-Ubuntu:~/c++_code$ g++ -pedantic -Wall -o TicTacToe{,_main.cpp,_rest.cpp}
/tmp/ccIx811o.o: In function `main':
TicTacToe_main.cpp:(.text+0x111): undefined reference to `C_choose(char*)'
collect2: ld returned 1 exit status
Last edited on
Your function is named C_chooce() but you're calling C_choose() (Notice the penultimate characters are wrong.)
Gah!!! That's annoying!
Sigh, thanks, friend.
No problem! I do this all the time, and I've been programming for awhile!
Topic archived. No new replies allowed.