I cant display a board for some reason I added a catch statemnt but there is something wrong with the if statment inside the for loop but i dont what is wrong thugh with the if else statement.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int size = 20;
void board_display(const bool [][size]);
void generations(bool [][size], bool [][size]);
int counting_neighbors(const bool [][size], int, int);
bool grid[size][size];
int main()
{
ifstream datafile;
cout << "The input values from the file will begin the first generation." << endl << endl;
// Initilize the grid to all dead cells
// bool grid[size][size];
/*
for (int i=0; i < size; i++)
for (int j=0; j < size; j++)
grid[i][j] = true;
*/
int row, column;
datafile.open("P3_input.dat");
if (!datafile)
{
cout << "File not found" << endl;
return 0;
}
else
while (datafile)
{
datafile >> row >> column;
if ( row >= 0 && row < size && column >= 0 && column < size) // checks for compatability
grid[row][column] = false;
}
//while ( row != -1);
board_display(grid);
bool temp[size][size];
return 0;
}
void board_display(const bool World[][size])
{
cout <<" 01234567890123456789\n";
for (int i=0; i < 20; i++)
{
cout <<"test first loop\n";
for (int j=0; j < 20; j++)
{
cout <<" test second loop\n";
if (grid[i][j] == true){
cout << "test 3" << endl;
cout << "*";
}
else cout << " ";
}
cout << endl;
}
}