Mail Archives: djgpp/1997/01/20/13:34:23
Hi,
Try this code.
Here i declare some struct with
members of unsigned char and unsigned int.
I think what sizeof(unsigned int)+sizeof(unsigned char)=5,
but I'm wrong! :-(
DGJPP think another way:
#include <stdio.h>
#include <conio.h>
#define BFLAG unsigned char //I think sizeof(BFLAG) - 1 byte
#define HND unsigned int //I think sizeof(HND) - 4 byte
typedef struct
{
BFLAG nCode;
HND hItem;
} TItem;
void main (void);
void main(void)
{
TItem pItem;
clrscr();
printf ("Size of BFLAG : %d\n",sizeof(BFLAG)); // 1
printf ("Size of HND : %d\n",sizeof(HND)); // 4
printf ("Size of TItem : %d\n",sizeof(TItem)); // 8
}
What i missing ?
Is it another trick of memory alligment ?
--
Regards,
Dim Zegebart,
Moscow Russia.
- Raw text -