Skip to content

Instantly share code, notes, and snippets.

@x684867
Created March 2, 2013 19:29
Show Gist options
  • Select an option

  • Save x684867/5072775 to your computer and use it in GitHub Desktop.

Select an option

Save x684867/5072775 to your computer and use it in GitHub Desktop.
This is a quick and dirty little program I use to determine how a machine and its operating system handle integer types. It's really nice when you are working with embedded systems. If you appreciate what I've done by making this a public domain script, then please contribute to one of the awesome open source projects on the internet or contribu…
#include <stdio.h>
#include <stdlib.h>
void main(void){
printf("word_sizes.c\n");
printf("(c) 2013 Sam Caldwell. Public Domain.\n\n");
printf("This is a quick and dirty little program I use to determine how a machine and its operating system handle integer types.\n\n");
printf("It's really nice when you are working with embedded systems. If you appreciate what I've done by making this a public domain script, ");
printf("then please contribute to one of the awesome open source projects on the internet or contribute your own code to the community and ");
printf("pay it forward.\n\n\n");
unsigned int c=sizeof(char)*8;
unsigned int word=sizeof(unsigned short int)*8;
unsigned int dword=sizeof(unsigned int)*8;
unsigned int qword=sizeof(unsigned long long)*8;
printf("-------------------------------------\n");
printf("char: %d bits (char) \n",c);
printf("word: %d bits (unsigned short int) \n",word);
printf("dword: %d bits (unsigned int)\n",dword);
printf("qword: %d bits (unsigned long long)\n",qword);
printf("-------------------------------------\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment