Dynamic Two-Dimensional Arrays

This is a discussion on Dynamic Two-Dimensional Arrays within the C++ Programming forums, part of the General Programming Boards category; Hey,
Well i was just working on an algorithm to read in a monochrome bitmap and then save each pixel ...

k, i just got home and i tried fixing it up like you said, at first it didnt compile so i edited until i could get it to compile, but now if i run the code it just exits, no errors or anything, just a clean exit, heres the code

Have you fixed this problem? I have used this method aswell, and as you can guess, Im having the same problem. These 2D arrays are annoying... Ive tried fixing it, but cant find the error. All I know is that its some form of runtime error, according to what the program said when it lagged and I read the first few words.

Your use of memset looks broken to me beucase you are taking the address bletter. Instead of using 2-d arrays, use the 1-d array. DWORD letter[width * height]. Becuase your algorithm to read does so sequentially, you can do so with a 1-nested loop.

Writing your loops in column major form is bad practice in C++ and could slow down the program because the memory accesses are not sequential. Instead, do

This will be probably faster because you will only use one dynamic allocation. Individual access into the array should probably be done with inline functions . For instance, you could write code similar to this
inline void set_pixel(int x, int y, val)
{
letter[x + y * width] = val;
}
[/code]

That might help him, but not me
My code uses a 2D array for storing data from a file, but the first 2 digits of the file tell it what the dimentions are, and then I make Dynamic Array for the data. Only problem is the same as his, it closes just as it opens. Mine just loads it normaly though, so I dont know what could be wrong. Heres Ill post some code:

And of course the deconstructor deletes the array, but the array doesnt work anyways... The program just closes near the start, while declaring the array Any tips? Did I mess up the declaring of the array?