Skip to content

Instantly share code, notes, and snippets.

@neonfuz
Created December 2, 2015 03:06
Show Gist options
  • Save neonfuz/ee9adbd06113a97aa1fb to your computer and use it in GitHub Desktop.
Save neonfuz/ee9adbd06113a97aa1fb to your computer and use it in GitHub Desktop.
Program to test the sizes of various types
#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