ok, so here is a link to my project guidelines...
http://www.santarosa.edu/~ssarkar/cs10sm09/cis10/proj5.html
by the way, the deadline was extended to 08/07/09
and here is my code for my program... it compiles and counts perfectly, but for my project i need the program to go from generation 1 to generation 2 to generation 3, etc... using the previous generation. the text file containing the data to be read into the program has been attached, its called "lifedata.txt, and here is my code. I desperately need help as i need to turn this in in 10 hours. I have also added the output to the end of my code.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <cassert>
using namespace std;

const int SIZE = 20;
int countNeighbors(bool life[][SIZE], int row, int col);
void printGrid1(bool [][SIZE]);
void printGrid2(bool [][SIZE]);
void readGrid(bool [][SIZE]);
void initGrid(bool life[][SIZE]);
void determineNextGen(bool [][SIZE], bool [][SIZE]);



int main()
{
   bool life[SIZE][SIZE];
   bool life2[SIZE][SIZE];
      
   
   initGrid(life);
   initGrid(life2);
   //printGrid1(life);
   readGrid(life);   
   printGrid2(life);    
   
   determineNextGen(life,life2);
 
    system ("PAUSE");
    return 0;
}

int countNeighbors(bool life[][SIZE], int row, int col)
{
    int count = 0;
    for (int rowCount = row-1; rowCount <= row+1; rowCount++){
        for (int colCount = col-1; colCount <= col+1; colCount++){
            if (rowCount >= 0 && rowCount < SIZE && colCount >=0 && colCount < SIZE){
                if (life[rowCount][colCount]){ 				                  
                    count++;
                }
            }
        }
    }
	
    if (life[row][col]){	//because we counted life[row][col] as a neighbor
        count--;
    }
	
    return count;
}

void determineNextGen(bool life[][SIZE], bool life2[][SIZE])
{
          int count=0;
   for(int row=0;row<SIZE;row++)
   {  
       for(int col=0;col<SIZE;col++)
       { 
            
          count=countNeighbors(life, row, col);
          if(life[row][col] && (count <2 ||count>3))
          {
           life2[row][col]=true;
          }
          
           if(!life[row][col] && count==3)
          {
           life2[row][col]=true;
          }
            
        }       
    }
}               


void printGrid1(bool life[][SIZE])
{
         //print contents of array after initialization
    	cout << "  01234567890123456789" << endl;
    for (int row = 0; row < SIZE; row++)
    {
        cout << setw(2) << row;
        for (int col = 0; col < SIZE; col++)
        {
           cout<<life[row][col];
        }
        cout << endl;
}
     
}
void printGrid2 (bool life[][SIZE])
{
     //print contents of two-dimensional array
    
	cout << "  01234567890123456789" << endl;
    for (int row = 0; row < SIZE; row++)
    {
        cout << setw(2) << row;
        for (int col = 0; col < SIZE; col++)
        {
            if (life[row][col])
            {
                cout << "*";
            } 
            else 
            {
                cout << " ";
            }
        }
        cout << endl;       
} 
        //total alive in row 10
        int row=10;
        int rowtotal=0;
        for (int col = 0; col < SIZE; col++)
        {
            if(life[row][col])
            rowtotal=rowtotal+1;
        }
        cout<<"total alive in row 10 is "<<rowtotal<<endl;
        //total alive in col 10
        int col=10;
        int coltotal=0;
        for (int row = 0; row < SIZE; row++)
        {
            if(life[row][col])
            coltotal=coltotal+1;
        }
        cout<<"total alive in column 10 is "<<coltotal<<endl;
        //total alive in grid  
        int totalalive=0;
         for (int row = 0; row < SIZE; row++)
    {
        for (int col = 0; col < SIZE; col++)
        {
           if( life[row][col])
           totalalive++;
        }
    }   
    cout<<"total alive cells is "<<totalalive<<endl; 
}


void initGrid(bool life[][SIZE])
{
     for(int row=0;row<SIZE;row++)
     {
       for(int col=0;col<SIZE;col++)
       {
        life[row][col]=0;
        }
        }
}      

void readGrid(bool life[][SIZE])
{
    ifstream inData;
    string fileName;
    int row, col;
    cout<<"Please enter filename"<<endl;
    cin>>fileName;
    inData.open(fileName.c_str());
    
   inData>>row>>col;
   while(inData)
   {
     life[row][col]=true;
      inData>>row>>col;
   }       
} 

/* OUTPUT

Please enter filename
lifedata.txt
  01234567890123456789
 0*    *   *         *
 1      *       * *
 2    *  *   *  *** *
 3  *  *   **      * *
 4*  * *   *
 5  ** *         ***
 6     **   ** **  **
 7      * *     * *
 8 *   *  * *      *
 9   ** **
10*        *         *
11 *** * **     *  * *
12    *** *
13**     *  **  *****
14  *        * * * * *
15           * *    *
16 **  *  *        *
17     **
18      *         * *
19*  **  *
total alive in row 10 is 3
total alive in column 10 is 4
total alive cells is 100
Press any key to continue . . .

*/
Attachments
0   0
   0   5
   0   9
   0  19
   1   6
   1  14
   1  16
   2   4
   2   7
   2  11
   2  14
   2  15
   2  16
   2  18
   3   2
   3   5
   3   9
   3  10
   3  17
   3  19
   4   0
   4   3
   4   5
   4   9
   5   2
   5   3
   5   5
   5  15
   5  16
   5  17
   6   5
   6   6
   6  10
   6  11
   6  13
   6  14
   6  17
   6  18
   7   6
   7   8
   7  14
   7  16
   8   1
   8   5
   8   8
   8  10
   8  17
   9   3
   9   4
   9   6
   9   7
  10   0
  10   9
  10  19
  11   1
  11   2
  11   3
  11   5
  11   7
  11   8
  11  14
  11  17
  11  19
  12   4
  12   5
  12   6
  12   8
  13   0
  13   1
  13   7
  13  10
  13  11
  13  14
  13  15
  13  16
  13  17
  13  18
  14   2
  14  11
  14  13
  14  15
  14  17
  14  19
  15  11
  15  13
  15  18
  16   1
  16   2
  16   5
  16   8
  16  17
  17   5
  17   6
  18   6
  18  16
  18  18
  19   0
  19   3
  19   4
  19   7

Dunno if something like this is in the ballpark:

for ( int i = 0; i < 20; ++i )
   {
      printGrid2(life);    
      determineNextGen(life,life2);
      memcpy(life, life2, sizeof life);
   }

THANKS A TON!
I changed it up so the user could enter the number of generations they would like to see...
if you ever want any "favors" i owe you one lol... jk, but seriously, u saved my grade haha, even with how simple that was.
again... THANK YOU!

Hello Slayerace180,
Please don't put titles like your, put what is the real problem, read the forum rules!

Thanks,
Nathan Paulino Campos

This article has been dead for over six months. Start a new discussion instead.