Character arrays

I'm supposed to be designing a game for my final project for my introduction to C++ class. I'm having trouble with arrays, character arrays to be specific and I'm not sure if what i'm trying to do is doable or not. I'm trying to put characters as follows:

+,-,|,X,O

into my character array in different orders to form an board so that I can use another array to point to certain matrix coordinates in it to update the board. Everytime I try to put the character into the array manually and declare each grid coordinate, it keeps giving me an error saying that the variable is undeclared or a function is expected before the + or - sign.

This is my code thus far.

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
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main ()
{
	int inputArray[9][9] = {};		//array used to get user input and update board
	char asciiBoard[37][19];		//array to store board characters in
	int x = 1, y = 1;           //used as part of my test in for statements
	string playGame;
	
	cout <<	"                                                                                                                                     "
		 << "\n    cccccccccccccccc   ooooooooooo   nnnn  nnnnnnnn       qqqqqqqqq   qqqqquuuuuu    uuuuuu      eeeeeeeeeeee    rrrrr   rrrrrrrrr   "
		 << "\n  cc:::::::::::::::c oo:::::::::::oo n:::nn::::::::nn    q:::::::::qqq::::qu::::u    u::::u    ee::::::::::::ee  r::::rrr:::::::::r  "
		 << "\n c:::::::::::::::::co:::::::::::::::on::::::::::::::nn  q:::::::::::::::::qu::::u    u::::u   e::::::eeeee:::::eer:::::::::::::::::r "
		 << "\nc:::::::cccccc:::::co:::::ooooo:::::onn:::::::::::::::nq::::::qqqqq::::::qqu::::u    u::::u  e::::::e     e:::::err::::::rrrrr::::::r"
		 << "\nc::::::c     ccccccco::::o     o::::o  n:::::nnnn:::::nq:::::q     q:::::q u::::u    u::::u  e:::::::eeeee::::::e r:::::r     r:::::r"
		 << "\nc:::::c             o::::o     o::::o  n::::n    n::::nq:::::q     q:::::q u::::u    u::::u  e:::::::::::::::::e  r:::::r     rrrrrrr"
		 << "\nc:::::c             o::::o     o::::o  n::::n    n::::nq:::::q     q:::::q u::::u    u::::u  e::::::eeeeeeeeeee   r:::::r            "
		 << "\nc::::::c     ccccccco::::o     o::::o  n::::n    n::::nq::::::q    q:::::q u:::::uuuu:::::u  e:::::::e            r:::::r            "
		 << "\nc:::::::cccccc:::::co:::::ooooo:::::o  n::::n    n::::nq:::::::qqqqq:::::q u:::::::::::::::uue::::::::e           r:::::r            "
		 << "\n c:::::::::::::::::co:::::::::::::::o  n::::n    n::::n q::::::::::::::::q  u:::::::::::::::u e::::::::eeeeeeee   r:::::r            "
		 << "\n  cc:::::::::::::::c oo:::::::::::oo   n::::n    n::::n  qq::::::::::::::q   uu::::::::uu:::u  ee:::::::::::::e   r:::::r            "
		 << "\n    cccccccccccccccc   ooooooooooo     nnnnnn    nnnnnn    qqqqqqqq::::::q     uuuuuuuu  uuuu    eeeeeeeeeeeeee   rrrrrrr            "
		 << "\n                                                                   q:::::q                                                           "
		 << "\n                                                                   q:::::q                                                           "
		 << "\n                                                                  q:::::::q                                                          "
		 << "\n                                                                  q:::::::q                                                          "
		 << "\n                                                                  q:::::::q                                                          "
		 << "\n                                                                  qqqqqqqqq                                                          \n\n";                                                                                                                                   
	cout << endl;

	cout << "Would you like to play Conquer? Enter Yes or No: ";
	cin >> playGame;
	cout << endl;

	if (playGame == "No" || playGame == "no")
	{
		return 0;
	}


	cout << "Conquer is a two player game in which players battle each other for control of the board.\n"
		 << "To win a game of Conquer, every space on the board must be filled and the player with the\n"
		 << "most pieces wins. Players are allowed one move per turn. Players can move one of their pieces\n"
		 << "any number of spaces in any direction. Moving your piece one space will duplicate that piece\n"
		 << "to that space. If players move their piece more than one space, they will move their piece\n"
		 << "without duplicating it to the new space. If a player moves their piece into a space bordering\n"
		 << "enemy pieces, those pieces are converted into pieces of the player who made the move. Player \n"
		 << "pieces can be convertedany number of times so long as an empty space is bordering it. The player\n"
		 << "pieces will be a 'X' and an 'O'. To move your piece, players will be asked to enter the grid\n"
		 << "location for their piece and the grid location for where they would like to move it.\n\n";
	cout << endl;
	
	cout << setw(50) << "This will be your board for the game\n\n"
         << setw(50) << "    +---+---+---+---+---+---+---+	    \n"		
		 << setw(50) << "    | 1 | 2 | 3 | 4 | 5 | 6 | 7 |	    \n"		
		 << setw(50) << "+---+---------------------------+---+ \n"		
		 << setw(50) << "| 1 | X |   |   |   |   |   | O | 1 | \n"		
		 << setw(50) << "+---|---+---+---+---+---+---+---|---+ \n"
		 << setw(50) << "| 2 |   |   |   |   |   |   |   | 2 | \n"
		 << setw(50) << "+---|---+---+---+---+---+---+---|---+ \n"
		 << setw(50) << "| 3 |   |   |   |   |   |   |   | 3 | \n"
		 << setw(50) << "+---|---+---+---+---+---+---+---|---+ \n"
		 << setw(50) << "| 4 |   |   |   |   |   |   |   | 4 | \n"
		 << setw(50) << "+---|---+---+---+---+---+---+---|---+ \n"
		 << setw(50) << "| 5 |   |   |   |   |   |   |   | 5 | \n"
		 << setw(50) << "+---|---+---+---+---+---+---+---|---+ \n"
		 << setw(50) << "| 6 |   |   |   |   |   |   |   | 6 | \n"
		 << setw(50) << "+---|---+---+---+---+---+---+---|---+ \n"
		 << setw(50) << "| 7 | O |   |   |   |   |   | X | 7 | \n"
		 << setw(50) << "+---|---+---+---+---+---+---+---|---+ \n"
		 << setw(50) << "    | 1 | 2 | 3 | 4 | 5 | 6 | 7 |	    \n"
		 << setw(50) << "    +---+---+---+---+---+---+---+	   \n\n";
	cout << endl;

    for (int c = -1; c <= 1; c++)				//for statements helping me test
    {                                           //to make sure I can change data
            for (int i = -1; i <= 1; i++)       //in my array to "convert" pieces
            {
                if (inputArray[y+c][x+i] == 0)
				{
					inputArray[y+c][x+i] = 1;
				}
			}
    }
	
    for (int c = 1; c < 8; c++)					
    {
            for (int i = 1; i < 8; i++)
            {
				cout << inputArray[c][i] << " ";
            }
		cout << endl;
    }
    char scrnHold;
    cin >> scrnHold;

	return 0;
}
Could you show the code you use to input into the array?
I don't have any code made up to input into the asciiBoard array. I was asking if anyone could help me with that. I couldn't think of how to do it and come out with what I have designed atm. I was trying to also manually input the board into the array but that wasn't working. What I mean by manually inputting the board into the array would be like what I'm doing currently with the inputArray with the code i've currently wrote up for the game today.

1
2
int inputArray[9][9] = {{},{ 0, 1, 0, 0, 0, 0, 0, 2, 0},{},{},{},{},{},{ 0, 2, 0, 0, 0, 0, 0, 1, 0},{}};
		//Setting up input board for play 
To manually input into the asciiBoard array use code similar to this:
asciiBoard[2][4] = '+';
Remember to use single quotes, not double quotes around the character.
Awesome. I got it to work. Thanks. I think I was trying to use full quotes instead of single and it didn't even occur to me. It's always the little things.
Topic archived. No new replies allowed.