sizeof

The sizeof program uses the C sizeof() call to display the size (in bytes) of the standard C data types (char, int, long,...). Execute sizeof as follows:

    sizeof 

Example

sms> sizeof

C
sizeof (char)	= 1
sizeof (double)	= 8
sizeof (float)	= 4
sizeof (int)	= 4
sizeof (long)	= 4
sizeof (long long)	= 8
sizeof (short)	= 2
sizeof (void *)	= 4

sizeof (clock_t)	= 4
sizeof (pid_t)	= 4
sizeof (size_t)	= 4
sizeof (ssize_t)	= 4
sizeof (time_t)	= 4
sms> 

sizeof.c

sizeof.c simply calls the sizeof() for each standard data type.

The printsize() macro ensures that the program output is consistent, that the data type name and size are displayed consistently. The use of # within macros is described in in section A12.3 of Kernighan & Ritchie.

You can modify this code to display the size of your own data structures. Simply include the appropriate header files and add your own printsize() call.

Home