ok, so ive rattled my brain for quite some time now and im tired, i need help on my program because as of now, im down to 2 debugging errors "YAY!"...
here is what the debugger says...
"
Line 7: error: too few arguments to function `void nextArray(bool (*)[20])'
Line 25: error: at this point in file
Line 8: error: too few arguments to function `void printArray(bool (*)[20])'
Line 26: error: at this point in file
"
and here is my code...
#include <iostream>
#include <fstream>
using namespace std;
const int SIZE = 20;
void lifegrid(int , int , bool [] [SIZE]);
void nextArray(bool [] [SIZE]);
void printArray(bool [] [SIZE]);
int main ()
{
bool life[SIZE][SIZE];
string keyboardinput;
do {
keyboardinput = "";
cout << "Enter \"n\" for next cycle, anything else to quit... ";
cin >> keyboardinput;
cout << endl;
nextArray();
printArray();
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;
} while (keyboardinput == "n");
cout << "Goodbye." << endl;
system("PAUSE");
return 0;
}
void lifegrid(int a, int b, bool life[] [SIZE]) {
int row, col;
row = a;
col = b;
ifstream inData;
string fileName;
cout<<"Please enter filename"<<endl;
cin>>fileName;
inData.open(fileName.c_str());
inData>>row>>col;
while(inData)
{
life[row][col]=true;
inData>>row>>col;
}
}
void nextArray(bool life[] [SIZE]) {
int row, col;
int numAround = 0;
bool templife [row][col];
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col ; j++)
{
if ( (i+1) < row && life[i + 1][j] == true )
{
numAround++;
}
if ( (i-1) >= 0 && life[i - 1][j] == true )
{
numAround++;
}
if ( (j+1) < col && life[i][j+1] == true )
{
numAround++;
}
if ( (j-1) >= 0 && life[i][j-1] == true )
{
numAround++;
}
if ( (i+1) < row && (j+1) < col && life[i+1][j+1] == true )
{
numAround++;
}
if ( (i+1) < row && (j-1) >= 0 && life[i+1][j-1] == true )
{
numAround++;
}
if ( (i-1) >= 0 && (j+1) < col && life[i-1][j+1] == true )
{
numAround++;
}
if ( (i-1) >= 0 && (j-1) >= 0 && life[i-1][j-1] == true )
{
numAround++;
}
if (numAround < 2 || numAround > 3)
{
templife[i][j] = false;
}
else if (numAround == 2)
{
templife[i][j] = life[i][j];
}
else if (numAround == 3)
{
templife[i][j] = true;
}
numAround = 0;
}
}
for (int i = 0 ; i < row ; i++ )
{
for (int j = 0 ; j < col ; j++ )
{
life[i][j] = templife[i][j];
}
}
}
void printArray(bool life[] [SIZE]) {
int row, col;
for (int i = 0; i < row ; i++ )
{
for (int j = 0 ; j < col ; j++ )
{
if ( life[i][j] == true )
{
cout << "x";
}
else
{
cout << " ";
}
if ( (j + 1) >= col )
{
cout << endl;
}
}
}
}
i know its kind of crappy and a bit hacked together, but thats how i role... my hair is a mess too... help would be much appreciated, as the program is due in 21 hours... i am eager to learn anything you guys can throw at me to fix what i need to fix to get this program off my back.
thanks a bunch, hope some 1 can help me ^_^