Here ya go:

HAL9000:~/dumexamples$ cat sizeof.c
#include <stdio.h>
#include <stdlib.h>

void main()
{
  char a;
  short f;
  int b;
  long c;
  float d;
  double e;

  puts("Variable sizes:");
  printf("Size of a character = %i\n",sizeof(a));
  printf("Size of a short = %i\n",sizeof(f));
  printf("Size of an integer  = %i\n",sizeof(b));
  printf("Size of a long = %i\n",sizeof(c));
  printf("Size of a float = %i\n",sizeof(d));
  printf("Size of a double = %i\n",sizeof(e));
}

HAL9000:~/dumexamples$ ./sizeof
Variable sizes:
Size of a character = 1
Size of a short = 2
Size of an integer  = 4
Size of a long = 4
Size of a float = 4
Size of a double = 8

This code came from C For Dummies (hence the subdir dumexamples) - to be
used as an example to show the size of the various data types.  If there
are any other data types that you want to investigate, just add 'em in. 
The method should be fairly easy to determine from the above code.  BTW
- the sizes shown are in bytes.

It's actually somewhat interesting to run this code on various systems
to see the differences.
-- 
Mike Werner  KA8YSD           |  "Where do you want to go today?"
ICQ# 12934898                 |  "As far from Redmond as possible!"
'91 GS500E                    |
Morgantown WV                 |  Only dead fish go with the flow.

Reply via email to