Showsize

From Federal Burro of Information
Jump to navigationJump to search

a c program to tell you what the size of data types are:

showsize.c

#include <sys/types.h>
#include <stdio.h>

int main(void)
{
        printf("In bits:\n");
        printf("%d <-unsigned long\n",  sizeof(unsigned long)*8); /* mul8 to get it in bits */
        printf("%d <-unsigned long\n",  sizeof(unsigned long)); /* mul8 to get it in bits */
        printf("%d <-long long\n",      sizeof(long long)*8); /* mul8 to get it in bits */
        printf("%d <-int\n",            sizeof(int)*8); /* mul8 to get it in bits */
        printf("%d <-unsigned int\n",   sizeof(unsigned int)*8); /* mul8 to get it in bits */
        printf("%d <-unsigned int\n",   sizeof(unsigned int)*8); /* mul8 to get it in bits */
        return 0;
}

compile is simple:

gcc showsize.c -out showsize

There are warnings.

sample out:

In bits:
64 <-unsigned long
8 <-unsigned long
64 <-long long
32 <-int
32 <-unsigned int
32 <-unsigned int