error! function does not take 0 arguments PLEASE HELP!!! DESPERATE TO FINISH THIS PROGRAM

Pages: 12
Greetings. I've been writing this simple Tic Tac Toe program when I faced this error, function does not take 0 arguments. I've tried all sort of things, however, could not come with a solution. Note that this is an incomplete program, however, please help to finish it!! (Apologies for the excess amount of comments, I've commented because I have to present it.)

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
95
96
97
98
99
100
101
102
103
104
105
106
  //3T, or TicTacToe by Jay.
#include <iostream>
#include <string>
//Libraries
using namespace std;
/*****************************************************************/
//Function Declaration
/*****************************************************************/
void welcomeMessage();
//welcomeMessage() ---> Displays welcoming message
void insText();
//insText() ---> Instructions
void endSpace();
//endSpace() ---> Spaces (endl, endl, endl || \n, \n, \n)
void tttBoard();
//tttBoard() ---> Tic Tac Toe Board in the beginning
int playTurn(int);
//playTurn() ---> The Turn, whether it's P1's or P2's.

/**********************************************/
char bSquare[] = {'1','2','3','4','5','6','7','8','9'};
//Bad Programming, as variables shouldn't be declared out of function. 
//Only const _____ should be on global declaration.
//Made for simplicity, as parameters are confusing, apologies to whoever is reading this.
/**********************************************/

//Main Function
int main() {
	int i; //i is the variable for the loop
	//also used in the turn count;
	
	



	welcomeMessage(); //Function welcomeMessage, which displays welcoming message.
	//It also includes a system("PAUSE"); that pauses the system temporarily.
	i=0;
	do {
	/****************************************************************/
	endSpace(); //Function endSpace--->Blank Lines
	/***************************************************************/
	
	insText(); //Function insText--->Instructions
	//Right before the board, NO PAUSES

	tttBoard(); //Function tttBoard displays the TicTacToe's 3 x 3 board.
	//Numbers are marked for each square
	} while(i<9);
system ("PAUSE");
return 0;
//returns the value 0, otherwise ends the program.
}

/******************************************************************/
//Function Description********************************************/
/*****************************************************************/

//Function: welcomeMessage ---> Displaying welcoming message & a pause. 
void welcomeMessage(){
	cout << "Hello~! Welcome to 3T, or \"TicTacToe\" This is a 2 player game on a 3 x 3 board. \n";
	//The Welcoming Message is stated*************************************\n ends the line, same as endl
	system("PAUSE"); //Displays "Press any key to continue" 
	//Temporarily pauses the program. 
}

//Function: tttBoard ---> Displays the Tic Tac Toe 3 x 3 board. 
void tttBoard(){
	//TicTacToe Board is below
	cout << "_" << bSquare[0] << "_|_" << bSquare[1] << "_|_" << bSquare[2] << "_" << endl; //endl is used instead of \n because of "beautiful code"
	//First line of Table^
	cout << "_" << bSquare[3] << "_|_" << bSquare[4] << "_|_" << bSquare[5] << "_" << endl; //endl is used instead of \n because of "beautiful code"
	//Second line of Table^
	cout << "_" << bSquare[6] << "_|_" << bSquare[7] << "_|_" << bSquare[8] << "_" << endl; //endl is used instead of \n because of "beautiful code"
	//Third line of Table^
	
	//***IMPORTANT***//
	//bSquare[x]=x+1; 
}

//Function endSpace ---> Just blankspaces for clearance.
void endSpace(){
	cout << "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n";
	//Numerous empty lines.
}

//Function: insText ---> Displays instructions for the users
void insText(){
	cout << "Player 1 is \"O\" and Player 2 is \"X.\" ";
	playTurn(); 
	cout << " Input \na number that's labeled in the square. \n";
	//Gives a brief introduction to how the game works. Numbers ---> Squares. 
}

//Function: playTurn ---> Calculates who's turn it is
int playTurn(int x){
	
	if (x==0 || x==2 || x==4 || x==8){ //This checks if it's Player 1's turn
		cout << "It's Player 1's turn." << endl; //Displays that it's Player 1's turn.
	}//Ending brace of the if statement in playTurn();

	else { //The rest is automatically Player 2's, as the user cannot make a change to this variable as an input.
		cout << "It's Player 2's turn." << endl; //Displays who's turn it is
	}//Ending brace of the else statement in playTurn();
	return 0;
}
What word do you not understand in this phrase "function does not take 0 arguments"?
I really don't understand why that error is showing, and also, what's the problem?
I'm a fob so I really don't speak english well.. sorry
One more what word do you not understand in this phrase "function does not take 0 arguments"?
You've posted an incomplete error message. The message should tell you which function doesn't take 0 arguments, and what line the error is on. That should give you a pretty good indication as to what's wrong with your code.
the '0 arguments' part sir.
error C2660: 'playTurn' : function does not take 0 arguments is on line 90
Right. So it should be obvious then.

How many arguments does playTurn take, in your definition of it?

How many arguments are you calling it with on line 90?
@UnitedJayMo

the '0 arguments' part sir.


It means that the function requires to specify arguments. You declared function
playTurn as

int playTurn(int);

but called it without any argument

1
2
3
void insText(){
	cout << "Player 1 is \"O\" and Player 2 is \"X.\" ";
	playTurn(); 

What do you mean by an argument?
Yes. But when you wrote your playTurn function, you decided that it should take an argument. Why are you now trying to call it without that argument?
What do you mean by an argument?

It's the thing that you pass into a function.
Oh.. I think I'm kinda getting it. Sorry for my lack of knowledge, I'm a noob. So I'm trying to make the function playTurn(); determine who's turn is it by adding 1 to i each and every turn. So how should I solve this? I'm so sorry if I'm being idiotic as heck.
I think there is no any sense to help you because it is not you who wrote the code.
I did write this code, and I claim 100% of it.
If you wrote the playTurn function, then you decided that it needed to take an argument , which you have called x (which is not a very helpful name, as it tells us nothing about its purpose).

Why, then, have you decided not to pass an argument in, when you call it at line 90?
I don't know what you mean by 'have you not decided not to pass an argument in,' could you explain please?
Last edited on
UnitedJayMo, did you even try to write the old (Hello World!) program????
i really wonder.
Look at line 90. Look at the way you're calling playTurn. How many arguments are you passing into the function in that call?
Pages: 12