c05c0ed918b4ded91b90d45a1751eb30876ccdd4
[sws1-1415.git] / ass2 / mart / sws1-s4109503-s4202015 / exercise2.c
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 void print(char *address, unsigned int size)
5 {
6 printf("address: %p, size: %u, psize: %u\n", address, size, sizeof(address));
7 for(unsigned char i=0; i<size; i++)
8 {
9 int value = *((char*)(address+i));
10 printf("%p %x %u\n", address+i, value, value);
11 }
12 }
13
14 int main(void)
15 {
16 short i = 0x1234;
17 char x = -127;
18 long sn1 = 4109503;/*
19 long sn2 = 4202015;
20 int y[2] = {0x11223344, 0x443332211};*/
21 printf("address content (hex) content(dec)\n");
22
23 print((char *)&i, sizeof(i));
24 print((char *)&x, sizeof(x));
25 print((char *)&sn1, sizeof(sn1));
26 return 0;
27 }