I have a pointer called **pieces that points to an array of class type GamePieces that contain members pName and pType. I am trying store values in pieces[row][col].pType and then print the pieces in a matrix. My program crashes on this line of code:

while (pieces[row][col].pType == 'X' || pieces[row][col].pType=='O') {

Here's the code for the function:

void GameBoard::AssignPlayer1(int row, int col, GamePiece& p1)
{
	while (pieces[row][col].pType == 'X' || pieces[row][col].pType=='O') {
		cout << "Space is already taken, try again" << endl;
		cout << "row: ";
		cin >> row;
		row -= 1;	
		cout << "column: ";
		cin >> col;
		col -= 1;	
		cout << endl << endl;
	}
	strcpy(&pieces[row][col].pType, &p1.pType); 
}

Here's my print to screen function and my operator overload:

void GameBoard::RefreshBoard()
{
	int row;
	int col;
	for (row=0; row < size; row++) {
		for (col=0; col < size; col++) {
			cout << &pieces[row][col].pType;
		}
		cout << endl;
	}
	cout << endl << endl;
}
ostream& operator<<(ostream& os, const GamePiece& p)
{
	os << " " << p.pType << " " << endl;
	return os;
}

??????? What's wrong????

>What's wrong????
You created a new thread when you have an existing thread with THE SAME QUESTION! That's what's wrong. And this thread is locked; please direct further replies to the original thread. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.