accessing data inside an AUX_RGBImageRec structure

Hi guys,

I’ve got a bit of a weird error in my code, I’m loading a bitmap into an AUX_RGBImageRec structure and then trying to read the data out of the data array and into my own array so I can play around with it but I only seem to be accessing the first member of the array then it stops rather than running through the whole array (of size width x height x 3). Heres the code I think its something stupid but I can’t see it…

int SizeOfArray = 0;
unsigned char *DataArray;
int Counter = 0;
AUX_RGBImageRec *TextureImage;

// Load The Bitmap, Check For Errors, If Bitmap’s Not Found Quit
if ( TextureImage=LoadBMP(FileLocation) )
// calculate size of data array required
SizeOfArray = TextureImage->sizeXTextureImage->sizeY3;

	// alocate data array of required size
	DataArray = new unsigned char[SizeOfArray];

	// fill output array 
	for( Counter=0 ; Counter<SizeOfArray ; Counter++ );
		DataArray[Counter] = TextureImage->data[Counter];




  1. turn on “generate debug info”
  2. start your program in the debugger
  3. set a breakpoint right after the loadBMP() call
  4. press “step” repeatedly, keeping watch on
    the values of your local variables, until
    you figure out what’s going on.

I’ve found the error there was a ; after the for head. I surprised the compiler did not pick it up as bad syntax!

It is not bad syntax; it’s perfectly legal.
Many compilers have warnings for this case
though, if you turn them on. I guess I’ll
add advice 0) always turn on all compiler
warnings, and heed them even if they seem