char *Data;
Data = new char[2, 10]; // This would create an array with 2 row and 10 chars per row
// do stuff
delete [] Data;
My Site
char *Data;
Data = new char[2, 10]; // This would create an array with 2 row and 10 chars per row
// do stuff
delete [] Data;
char** data;data = new char*[length1];for (i = 0; i < length1; ++i)data = new char[length2];
typedef float ARRAY[3]; // Just as an example.ARRAY *TwoDArray;TwoDArray = new ARRAY[3];// And to delete...delete [] TwoDArray;
quote:Original post by Sand_Hawk
Thanks for all the help so far. I've used this method:char** data;data = new char*[length1];for (i = 0; i < length1; ++i)data = new char[length2];
I can write to the memory, but if I try to read it my programs crahes. I use Data[Y][X] to read 1 character.
char** data;data = new char*[length1];for (i = 0; i < length1; ++i)data[i] = new char[length2];
int iIndex = 0; ifstream FishFile(FileName, ios::binary); // Load X and Y dimensions from the file FishFile.read((char *)&DimX, sizeof(int)); FishFile.read((char *)&DimY, sizeof(int)); // Allocate dynamic array with size of the fish FishData = new char*[DimY]; for (iIndex = 0; iIndex < DimY; iIndex++) FishData[iIndex] = new char[DimX]; // Read the fish from file FishFile.read((char *)FishData, sizeof(FishData));