I know there are a lot of questions surrounding this topic. Read 'em, still having trouble. The common suggestion here for declaring an array of RGBTriples is something like the following:
RGBTRIPLE name[bi.biWidth];
(Just to be clear, in my implementation bi.biWidth contains the resized number of pixels, not the infile's number of pixels).
However, when I take the program through GDB, step by step, that initialization of the array just returns a pointer / address.
To make it a little more concrete, I am testing resize on small.bmp, using a resize factor of 4, so bi.biWidth is 12 (3 pixels originally, scaled up by a factor 4). If I go through GDB and initialize the name array of RGBTRIPLEs, then print out the name array, I get the value 0xbfffef80. If I print out name dereferenced, I just get a lone RGBTRIPLE. And if I print out bi.biWidth locally, it gives me the integer 12 as expected.
Yet if I initialize the array with a hard-coded value of 12 inside the brackets, the name array acts exactly as I would have expected. It gives me a 36 byte array with 12 RGBTRIPLEs in it when I print it.
I've spent several hours just trying to get this piece right and googling all manner of array initialization tutorials. Some say that you can initialize an array with a variable number of elements in C, others say you can't. Anyone have something to unstick me?
(I can post code if it helps, but in this case didn't want to get distracted by other potential errors in the code. This is much more of a conceptual question about initializing arrays of structs when using a variable for the number of elements in the array).