Created
December 2, 2015 03:06
-
-
Save neonfuz/ee9adbd06113a97aa1fb to your computer and use it in GitHub Desktop.
Program to test the sizes of various types
This file contains hidden or 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
#include <stdio.h> | |
int main(int argc, char *argv[]) | |
{ | |
#define PRINT_SIZEOF(type) printf("sizeof(" #type "):\t%lu bytes\n", sizeof(type)) | |
PRINT_SIZEOF(char); | |
PRINT_SIZEOF(short); | |
PRINT_SIZEOF(int); | |
PRINT_SIZEOF(long); | |
PRINT_SIZEOF(long long); | |
return 0; | |
} | |
/* | |
Output on 64 bit linux: | |
sizeof(char): 1 bytes | |
sizeof(short): 2 bytes | |
sizeof(int): 4 bytes | |
sizeof(long): 8 bytes | |
sizeof(long long): 8 bytes | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment