Hey, I am attempting to build a simple tic-tac-toe program. I haven't been programming long, and appear to have bumped into this problem. This is my code:
void drawGrid(char grid[3][3])
{
cout << " " << grid[1][1] << " | " << grid[1][2] << " | " << grid[1][3] << endl;
cout << "---|---|---\n";
cout << " " << grid[2][1] << " | " << grid[2][2] << " | " << grid[2][3] << endl;
cout << "---|---|---\n";
cout << " " << grid[3][1] << " | " << grid[3][2] << " | " << grid[3][3] << endl;
}
int main()
{
char grid[3][3];
printHeader(); //I haven't left in the printHeader function as it's just a
//cout and shouldn't be affecting anything.
drawGrid(grid);
return 0;
}
When i compile and run I see:
¶ | ═ | @
---|---|---
| x |
---|---|---
" | | Z
Can anybody point me in the right direction please?
Thanks guys.
Edit:
Also, can any of you help with what to use instead of system("CLS"); to clear the terminal window? I have read all about not using system(), but while searching google, they were the only results that popped up!
I had a feeling it was because they weren't initialized, but I wasn't sure how to with the multidimensional arrays. I will make sure I read more into them for future use.
I'm just trying to get my head around that code now :)
Thanks guys.
Edit@blackcoder41 "//here is the memset() why did you remove it?"
I hadn't, I was creating that post before you replied.