So I have three files for my program. My main.cpp looks like this:
#include <iostream>
#include <fstream>
#include <cstdlib>
#include "dtt0055HW4func.cpp"
#include "dtt0055HW4func.h"
using namespace std;
int main()
{
int size = 7;
char (*boardOfGame)[7] = new char[7][7];
int* sizeOfBoardGame = NULL;
sizeOfBoardGame = &size;
initializeBoardGame(boardOfGame, sizeOfBoardGame);
return 0;
}
And my func.h looks like this:
#ifndef dtt0055HW4func
#define dtt0055HW4func
enum typeOfTiles{CROSS = '+', HORIZONTAL = '-', VERTICAL = '|', LOCKED = 'X', EMPTY};
enum colorOfTiles{RED, BLUE};
struct tile{
typeOfTiles newTile;
colorOfTiles newTileColor;
int positionOfNewTile;
};
void initializeBoardGame(char (*boardOfGame)[7],int* sizeOfBoard);
#endif
Thanks, guy for your help on the first error. I have modified my program and it gives me a new issue in func.cpp. Now my func.cpp looks like this:
#include "dtt0055HW4func.h"
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
void initializeBoardGame(char (*boardOfGame)[7],int* sizeOfBoard)
{
char nameOfFile[30],c;
ifstream inFS;
cout << "Please enter the name of the input file: ";
cin >> nameOfFile;
inFS.open(nameOfFile);
if (inFS.fail())
{
while(inFS.fail())
{
cout << "Unable to open the file, please enter the name of the file again. " << endl;
cin >> nameOfFile;
inFS.open(nameOfFile);
}
}
while (!inFS.eof())
{
for (int i = 0; i < *sizeOfBoard; i++)
{
for (int j = 0; j < *sizeOfBoard; j++)
{
boardOfGame[i][j] = &inFS.get(c);
cout << boardOfGame[i][j];
}
cout << endl;
}
}
inFS.close();
}
Now my compiler gives me an error in the func.cpp error: invalid conversion from ‘std::basic_istream::__istream_type* {aka std::basic_istream*}’ to ‘char’ [-fpermissive] boardOfGame[i][j] = &inFS.get(c); What I'm trying to do in this line is to assign one character in the file to one index of my array. If i'm using boardOfGame[i][j] = inFS.get(c);, it will give me more errors.