Showsize

From Federal Burro of Information
Revision as of 18:41, 26 February 2023 by David (talk | contribs) (Created page with "a c program to tell you what the size of data types are: showsize.c <pre> #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",...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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;
}

Some errors need work on this. It used to work around the 2000s but now in 2023 not so much.