Thread overview
Variable sizes
Oct 03, 2004
IR
Oct 04, 2004
Heinz Saathoff
Oct 04, 2004
Scott Michel
October 03, 2004
With the Digital Mars compiler, how big (in bytes) are these variables?

unsigned int, int, unsigned short, short, unsigned long, long, and char

Thanks


October 04, 2004
Hello,

IR wrote...
> With the Digital Mars compiler, how big (in bytes) are these variables?
> 
> unsigned int, int, unsigned short, short, unsigned long, long, and char

depends on the memory model. In standard 32-bit windows the sizes are:

  unsigned int    and   int   : 32 bit
  unsigned short  and   short : 16 bit
  unsigned long   and   long  : 32 bit
  unsigned char   and   char  : 8 bit

HTH,
	Heinz
October 04, 2004
IR wrote:
> With the Digital Mars compiler, how big (in bytes) are these variables?
> 
> unsigned int, int, unsigned short, short, unsigned long, long, and char
> 
> Thanks

int main(void)
{
  printf("sizeof(unsigned int) = %d\n", sizeof(unsigned int));
  printf("sizeof(int) = %d\n", sizeof(int));
  printf("sizeof(unsigned short) = %d\n", sizeof(unsigned short));
  printf("sizeof(short) = %d\n", sizeof(short));
  printf("sizeof(unsigned long) = %d\n", sizeof(unsigned long));
  printf("sizeof(long) = %d\n", sizeof(long));
  printf("sizeof(char) = %d\n", sizeof(char));
  return 0;
}