I dont' know what this is... it gives me a run-time error (the program just craps)... I debugged it and the debugger said it was an "access violation (segment fault)" here:
Code:
for(v=0;v<vertical;v++) //loop through rows
{
if(debug)
vcount++;
for(h=0;h<horizontal;h++) //loop through cols
{
if(debug)
hcount++;
tank[v][h]=emptychar; //fill with empty space
}
}
and that is part of this class:
Code:
class lifeClass
{
public:
lifeClass(unsigned int,unsigned int,unsigned int);
//constructor (tank length,tank width,organism#)
void step(); //step through program
bool debg(); //returns bool debug
bool nextstep(); //returns true for another generation
~lifeClass(); //destructor
private:
void randxy(unsigned int&,unsigned int&); //randomizes X and Y
void drawtemptank(); //debug - Draws temporary tank
void drawtank(); //draws tank to screen
void copytank(); //copies next tank to current tank
char live(unsigned int,unsigned int); //living characters
char die(unsigned int,unsigned int); //dying characters
unsigned int countNeighbors(unsigned int,unsigned int); //counts neighbors
bool debug; //debugging statements - see lifeClass
bool cont; //continue to next generation?
char tank[][]; //living space
char emptychar,fillchar,killchar,bornchar; //characters used
unsigned int vertical,horizontal; //length and width of living space
unsigned int clickcount; //counts clicks (steps) taken by the program
};
I would appreciate some help with what this is, and if there's a better way (which I'm sure there is) to write a 2D (array of arrays) array, please post...
secondly, you define a new char array like this
Code:
char *array=new char[int];
but how/can you do that for a 2D array? and how do you delete a 2D array?
sorry for all the questions, but, well, I have a lot of questions