Skip to content

Instantly share code, notes, and snippets.

@davidbalbert
Created March 6, 2012 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidbalbert/1987568 to your computer and use it in GitHub Desktop.
Save davidbalbert/1987568 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(int argc, const char *argv[])
{
printf("sizeof(char) = %lu\n", sizeof(char));
printf("sizeof(short) = %lu\n", sizeof(short));
printf("sizeof(int) = %lu\n", sizeof(int));
printf("sizeof(long) = %lu\n", sizeof(long));
printf("sizeof(long long) = %lu\n", sizeof(long long));
printf("sizeof(float) = %lu\n", sizeof(float));
printf("sizeof(double) = %lu\n", sizeof(double));
printf("sizeof(long double) = %lu\n", sizeof(long double));
printf("sizeof(char *) = %lu\n", sizeof(char *));
printf("sizeof(int *) = %lu\n", sizeof(int *));
return 0;
}
@haveahennessy
Copy link

Why sizeof on pointer types? Pointers should all be the same size, no matter what their type.. (32/64-bit depending on your platform)

@davidbalbert
Copy link
Author

It was a teaching tool to demonstrate exactly that point :)

@haveahennessy
Copy link

Ha.. nice! sorry for being a smartass then d-:

@davidbalbert
Copy link
Author

Hehe. Don't worry about it :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment