CS 326 Operating Systems

sizes.c

DownloadView Raw

/**
 * sizes.c
 *
 * Reports the sizes of various C types
 */

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    printf("char      = %lu\n", sizeof(char));
    printf("int       = %lu\n", sizeof(int));
    printf("long      = %lu\n", sizeof(long));
    printf("long long = %lu\n", sizeof(long long));
    printf("float     = %lu\n", sizeof(float));
    printf("double    = %lu\n", sizeof(double));
    printf("int *     = %lu\n", sizeof(int *));
    printf("uint8_t   = %lu\n", sizeof(uint8_t));
    printf("size_t    = %lu\n", sizeof(size_t));

    return 0;
}