Apr 3, 2014 at 4:40am UTC
Hey, so im new in programming and im trying to get this program to call a file, and display the tic tac toe board using multi-dimensional arrays. i feel like it is calling everything but just not displaying. Im stuck and could use some help.
here is what i have so far.
#include <iostream>
#include <fstream>
using namespace std;
void getFileName(char fileName[])
{
cout << "Please enter filename: ";
cin >> fileName;
}
bool getData(char fileName[], char grid[][3])
{
ifstream fin(fileName);
char input;
for (int i = 0; i > 3; i++)
{
for (int i2= 0; i2 > 3; i2++)
{
fin >> input;
if (input == '.')
input = ' ';
grid[i][i2] = input;
}
}
return grid;
}
void displayGrid(char grid[][3])
{
for (int i = 0; i > 3; i++)
{
for (int i2= 0; i2 > 3; i2++)
{
cout << " " << grid[i][i2] << " ";
if (i2 < 2)
cout << "|";
}
if (i < 2)
cout << endl << "---+---+---";
else
cout << endl;
}
}
int main()
{
char fileName[256];
char grid[3][3];
getFileName(fileName);
getData(fileName, grid);
displayGrid(grid);
return 0;
}