Skip to content

Instantly share code, notes, and snippets.

@housemeow
Created January 8, 2013 16:09
Show Gist options
  • Save housemeow/4485004 to your computer and use it in GitHub Desktop.
Save housemeow/4485004 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(){
int i=1234;
char* ch = (char*)&i;
printf("*ch=%d\n", *ch);
printf("*(ch+1)=%d\n", *(ch+1));
//range of char = -128~127
//-128 = 10000000
// 11010110
// -00101010
//(int) = 00000000 00000000 00000000 10000000
// 127 = 01111111
//(int) = 00000000 00000000 00000000 01111111
//big endian
//(int)1234= 00000000 00000000 00000100 11010010
//
//little endian
//(int)1234= 11010010 00000100 00000000 00000000
// 00101110
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment