I was expecting sizeof(TargaHeader) to be 18.typedef struct _TargaHeader {
unsigned char id_length, colormap_type, image_type;
unsigned short colormap_index, colormap_length;
unsigned char colormap_size;
unsigned short x_origin, y_origin, width, height;
unsigned char pixel_size, attributes;
} TargaHeader;
I get the result 20.
char = 1 byte = (1) length, (2) colormap, (3) imagetype + (4) colormap_size + (5) pixel_size + (6) attributes
short = 2 bytes = (1) colormap_index, (2) colormap_length, (3) x_origin, (4) y_origin, (5) width, (6) height
char 1 times 6 = 6 bytes
short 2 times 6 = 12 bytes
6 + 12 = 18
But I'm getting 20. I seem to missing something. Memory allocations are rounded up to blocks of 4, I assume?