Array game 8x8

I tried to compile the coding below.. but i couldnt get a 8x8 board.. Any idea how to fix 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
  char board [ROWS];
	cout <<"+-+-+-+-+-+-+-+-+"<< endl;
	
	int count = 1;
		for (int k=0; k<=count; k++)
			{
				cout <<"| ";
				count--;
				count = 4;
				for (int p=0; p<=count; p++)
				{	
					
					cout <<"| | | | | | | | |"<< endl;
					cout <<"+-+-+-+-+-+-+-+-+"<< endl;
					count--;
				}
			}
	
	
	int i;
		while(i<ROWS)
			{
				cout << board[i] <<"|";
				i++;
			}
			cout <<" a b c d e f g h " << endl;
Could you post all of your code?
Something like this?
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
#include <iostream>

using namespace std;

int main()
{
    int ROWS = 8;
    int COLS = 8;
    char board [COLS][ROWS];
    // fill board with period characters
    for (int row = 0;row < ROWS;row++)
    {
        for (int col =0; col < COLS; col++)
        {
            board[col][row] = '.';
        }
    }
    // draw board
    cout << "  A   B   C   D   E   F   G   H" << endl;
    cout << "+---+---+---+---+---+---+---+---+" << endl;
    for (int row = 0;row < ROWS;row++)
    {
        cout << "| " ;
        for (int col =0; col < COLS; col++)
        {
            cout << board[row][col] << " | ";
        }
        cout << endl;
        cout << "+---+---+---+---+---+---+---+---+" << endl;
    }


    return 0;
}

It would be better if u explained what your code did if your not going to post all of the code. But i created a function that will create and 8x8 board. Use this if it helps you in any way.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void Path_2()
{


	const int Board_Size = 15;


	for (int Board = Board_Size; Board > 0; Board--)
	{


		if (Board % 2 == 1)
			cout << "| | | | | | | | |" << endl;
		else
			cout << "+-+-+-+-+-+-+-+-+" << endl;


	}


}
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <iostream>
#include <cstdlib>
#include <string>
#include <stdio.h>  //switch
#include <fstream>  //input output text file
using namespace std;

void new_board();
void rules();
void menu();

const int ROWS = 8;
const int COLS = 8;
int main()
{
	char input;
	int answer;
	
	cout << endl;
	
	
	menu();
	int choices = 0;
	/*choices = menu();
	switch(choices)
	{
		case 1:
		{
			system("cls");
			new_board();
			break;
		}
		case 2:
		{
			system("cls");
			rules();
			break;
		}
		case 3:
		{	
			system("cls");
			cout <<"You've chose to quit the game. See you later!" << endl;
			exit(1);
		}
		default:
		{
			system("cls");
			cout <<"Invalid selection"<< endl;
			exit(1);
		}
	
	}*/
	
	cin >> answer;
	
	if (answer == 1) // new game
	{
		system("cls");
		new_board();
	}
	else if (answer == 2) // rules
	{
		system("cls");
		rules();
		system("pause");
		menu();
		cin >> answer;
		
	}
	else if (answer == 3)  // exit
	{
		system("cls");
		cout <<"You've chose to exit. See you later!"<< endl;
	}
	else
	{
		cout << endl;
		cout<<"Wrong Selection. Program ends."<< endl;
	}
		
	return 0;
}

void menu()
{
	system("cls");
	
	
	cout <<"----------------------------\n";
	cout <<"  Welcome to Othello game!\n";
	cout <<"----------------------------\n";
	cout <<"  1. New Game \n";
	cout <<"  2. Help \n";
	cout <<"  3. Quit \n";
	cout <<"----------------------------\n";
	cout <<"Enter your selection: ";
}

void new_board()
{
	
	char board [ROWS];
	cout <<"+-+-+-+-+-+-+-+-+"<< endl;
	
	int count = 16;
	for (int k=0; k<=count; k++)
		{
			cout <<"| ";
			count--;
			count = 5;
		for (int p=0; p<=count; p++)
			{	
				
				cout <<"| | | | | | | | "<< endl;
				cout <<"+-+-+-+-+-+-+-+-+"<< endl;
				count--;
			}
		}
		
	
	int i;
		while(i<ROWS)
			{
				cout << board[i] <<"|";
				i++;
			}
			cout <<" a b c d e f g h " << endl;
			
}

void rules()
{
	
	cout <<"-------------------------------------------------------------\n";
	cout <<"                Othello Game Rules\n";
	cout <<"-------------------------------------------------------------\n";
	cout <<"  1. Black always moves first \n";
	cout <<"  2. If you cannot outflank at least one opposing disc,\n"
	     <<"     your turn is forfeited and your opponent moves again.\n";
	cout <<"  3. A disc may outflank any discs in one or more rows\n"
		 <<"     in any directions at the same time.\n";
	cout <<"-------------------------------------------------------------\n";
	
	
}

	/*count = 5;
		for (int p=0; p<=count; p++)
		{	
			
			cout <<"| | | | | | | | |"<< endl;
			cout <<"+-+-+-+-+-+-+-+-+"<< endl;
			count--;
		}*/








@codewriter, thats a nice 8x8 array you got there.. how do you include abcdefgh x 12345678 ?
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
#include <iostream>

using namespace std;

int main()
{
    int ROWS = 8;
    int COLS = 8;
    char board [COLS][ROWS];
    // fill board with period characters
    for (int row = 0;row < ROWS;row++)
    {
        for (int col =0; col < COLS; col++)
        {
            board[col][row] = '.';
        }
    }
    // draw board
    cout << "    A   B   C   D   E   F   G   H" << endl;
    cout << "  +---+---+---+---+---+---+---+---+" << endl;
    for (int row = 0;row < ROWS;row++)
    {
        cout << row+1 << " | " ;
        for (int col =0; col < COLS; col++)
        {
            cout << board[row][col] << " | ";
        }
        cout << endl;
        cout << "  +---+---+---+---+---+---+---+---+" << endl;
    }


    return 0;
}

thank you for the help guys! God bless :D
Topic archived. No new replies allowed.