0

I would like to note that this is for John Conway's game of life but I must write it in C++. I am making a 10x10 version of the game and I am using jGRASPto write the code. I am having a problem when it is reading in the starting set of data from a text doc.

code for game

```
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
//using std::cout;
//using std::cin;
//using std::endl;
//using std::ios;
//using std::ifstream;
//using std::ofstream;
void printArray2(int array[][10], int rows, int cols);
void printArray3(int array[][10], int row, int col);
int main(void){
int a00 = 0,a01 = 0,a02 = 0,a03 = 0,a04 = 0,a05 = 0,a06 = 0,a07 = 0,a08 = 0,a09 = 0,
a10 = 0,a11 = 0,a12 = 0,a13 = 0,a14 = 0,a15 = 0,a16 = 0,a17 = 0,a18 = 0,a19 = 0,a20 = 0,
a21 = 0,a22 = 0,a23 = 0,a24 = 0,a25 = 0,a26 = 0,a27 = 0,a28 = 0,a29 = 0,a30 = 0,a31 = 0,
a32 = 0,a33 = 0,a34 = 0,a35 = 0,a36 = 0,a37 = 0,a38 = 0,a39 = 0,a40 = 0,a41 = 0,a42 = 0,a43 = 0,
a44 = 0,a45 = 0,a46 = 0,a47 = 0,a48 = 0,a49 = 0,a50 = 0,a51 = 0,a52 = 0,a53 = 0,a54 = 0,a55 = 0,
a56 = 0,a57 = 0,a58 = 0,a59 = 0,a60 = 0,a61 = 0,a62 = 0,a63 = 0,a64 = 0,a65 = 0,a66 = 0,a67 = 0,
a68 = 0,a69 = 0,a70 = 0,a71 = 0,a72 = 0,a73 = 0,a74 = 0,a75 = 0,a76 = 0,a77 = 0,a78 = 0,a79 = 0,
a80 = 0,a81 = 0,a82 = 0,a83 = 0,a84 = 0,a85 = 0,a86 = 0,a87 = 0,a88 = 0,a89 = 0,a90 = 0,a91 = 0,
a92 = 0,a93 = 0,a94 = 0,a95 = 0,a96 = 0,a97 = 0,a98 = 0,a99 = 0;
int array[10][10] = {{a00,a01,a02,a03,a04,a05,a06,a07,a08,a09},{a10,a11,a12,a13,a14,a15,a16,a17,a18,a19},
{a20,a21,a22,a23,a24,a25,a26,a27,a28,a29},{a30,a31,a32,a33,a34,a35,a36,a37,a38,a39},
{a40,a41,a42,a43,a44,a45,a46,a47,a48,a49},{a50,a51,a52,a53,a54,a55,a56,a57,a58,a59},
{a60,a61,a62,a63,a64,a65,a66,a67,a68,a69},{a70,a71,a72,a73,a74,a75,a76,a77,a78,a79},
{a80,a81,a82,a83,a84,a85,a86,a87,a88,a89},{a90,a91,a92,a93,a94,a95,a96,a97,a98,a99}};
// printArray2(array,10,10);
int o;
int p;
int num =1;
int m;
int n;
string snum;
ifstream inClientFile("input2.dat", ios::in);
if (!inClientFile)
{
cout<<"file could not be opened"<<endl;
exit(1);
}
// snum = inClientFile.getline();
// cout<<snum<<endl;
num =inClientFile.get();
while (!inClientFile.eof())
{
for(n=0; n<10; n++)// col. number
{
for(m=0; m<10; m++)// rows number
{
array[m][n]=num;// inClientFile.get();
}
}
num = inClientFile.get();
cout<<num<<endl;
}
printArray3(array,10,10);
return 0;
}
void printArray2(int array[][10], int rows, int cols){
int i, j;
cout<<"starting life."<<endl;
for (i=0; i<rows; i++)
{
for (j=0; j<cols; j++)
cout << array[j] << " ";
cout << endl;
}
cout<< endl;
}
printArray2 is same as printArray3
```

the input file looks like

```
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 1
```

PLEASE HELP THANK YOU VERY MUCH

*Edited 3 Years Ago by happygeek*: fixed formatting