hey,
Just having trouble with creating a 2d array in the heap memory.
my code goes something like this:
twoDarray = new char[iSize][iSize];
where iSize is passed into the method.
cheers,
ActionMan
hey,
Just having trouble with creating a 2d array in the heap memory.
my code goes something like this:
twoDarray = new char[iSize][iSize];
where iSize is passed into the method.
cheers,
ActionMan
ActionMan
"THE DAY IS MYNE!!!!
I'll take famouse titties for $400"
-Sean Connery, Saturday Night Live
sorry forgot to say that twoDArray is declared as follows..
char ** twoDarray;
ActionMan
"THE DAY IS MYNE!!!!
I'll take famouse titties for $400"
-Sean Connery, Saturday Night Live
You cannot do it like that. A char** is a pointer to a pointer!
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
I believe this is what you're looking for...
Code:char **NewMatrix(int rows, int columns) { char **matrix = new char*[rows]; while(rows) { matrix[--rows] = new char[columns]; memset(matrix[rows], 0, columns); } return matrix; } //...You MUST call this to free up the memory... void KillMatrix(char** matrix, int rows) { while(rows) delete [] matrix[--rows]; } int main(int argc, char *argv[]) { int i, rows = 20, cols = 50; char **strings = NewMatrix(rows, cols); for(i = 0; i < rows; i++) sprintf(strings[i], "\nString #%i", i+1); for(i = 0; i < rows; i++) { printf(strings[i]); getch(); } printf("\n\n\nDeallocating Array!"); getch(); KillMatrix(strings, rows); return 0; }
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
hey,
thanks.. that the way I origionally had it. I was hoping new was a little more advanced.
thanks for the help!!
cheers,
ActionMan