I need help?

Hi, i'm new to the forum but i need some help. Here is the code i have

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

using namespace std;

char board [9];

void showboard ();



int main ( )

{

	char board [9];

	board [0] = '0';
	board [1] = '1';
	board [2] = '2';
	board [3] = '3';
	board [4] = '4';
	board [5] = '5';
	board [6] = '6';
	board [7] = '7';
	board [8] = '8';

	showboard ();

}

void showboard ()
{
	cout << board [0] << "|" << board [1] << "|" << board [2] <<endl;
}


But the problem is that the numbers wont print to the screen. Any ideas why?

this is a school project and its going to be a tic tac toe game. I have been trying different things and i just cant figure out why it wont print the numbers. From what my lesson says, the exact same code i have should print the numbers to the screen but it does not.
The board declaration on line 15 "hides" the declaration on line 7. That means that when you put data in board in main, you are doing so with the local board, not the global one (the global board is the one that showboard uses).

Just remove line 15, do some Googleing on scope rules as well as the debacle surrounding the use of global variables.

Hope that helps
Yep! That worked great, thank you for your help!
Topic archived. No new replies allowed.