diff options
Diffstat (limited to 'CSAPP/chap2/endianess.c')
| -rw-r--r-- | CSAPP/chap2/endianess.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/CSAPP/chap2/endianess.c b/CSAPP/chap2/endianess.c new file mode 100644 index 0000000..c2c08aa --- /dev/null +++ b/CSAPP/chap2/endianess.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +int main(void) +{ + unsigned int a = 0xdc3f109a; + /* Preferred data type for expressing size of data structures */ + size_t i; + unsigned char *p; + + printf("Current value of variable: %x\n\n", a); + for (i = 0, p = (char *)&a; i < sizeof(int); i++) { + printf("Address: %p - Value %x\n", p, (unsigned char)*p); + p++; + } + + return 0; +} |
