Created
October 3, 2012 05:30
-
-
Save vobject/3825201 to your computer and use it in GitHub Desktop.
Sizes of C data types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* gcc -std=c99 -pedantic -Wall sizeof.c && ./a.out | |
* clang -std=c99 -pedantic -Wall sizeof.c && ./a.out | |
*/ | |
#include <stdio.h> | |
#include <stdbool.h> | |
#include <time.h> | |
#include <sys/time.h> | |
int main(void) | |
{ | |
printf("size_t: %zu\n", sizeof(size_t)); | |
printf("bool: %zu\n", sizeof(bool)); | |
printf("char: %zu\n", sizeof(char)); | |
printf("short: %zu\n", sizeof(short)); | |
printf("int: %zu\n", sizeof(int)); | |
printf("long: %zu\n", sizeof(long)); | |
printf("long long: %zu\n", sizeof(long long)); | |
printf("float: %zu\n", sizeof(float)); | |
printf("double: %zu\n", sizeof(double)); | |
printf("long double: %zu\n", sizeof(long double)); | |
printf("clock_t: %zu\n", sizeof(clock_t)); | |
printf("time_t: %zu\n", sizeof(time_t)); | |
printf("struct tm: %zu\n", sizeof(struct tm)); | |
printf("struct timeval: %zu\n", sizeof(struct timeval)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment