dd4a236f6cb2bad18d8db3f34c6e12266438c07d
[sws1-1415.git] / ass2 / mart / sws1-s4109503-s4202015 / exercise2.c
1 #include <stdio.h>
2 #include <stdint.h> /* Because typing unsigned char takes too much characters*/
3
4 void pm(uint8_t *a, size_t s)
5 {
6 for(uint8_t i = 0; i < s; i++)
7 printf("%p\t0x%02X\t\t%3u\n", a + i, *(a + i), *(a + i));
8 }
9
10 int main(void)
11 {
12 short i = 0x1234;
13 char x = -127;
14 long sn1 = 4109503;
15 long sn2 = 4202015;
16 int y[2] = {0x11223344, 0x44332211};
17 printf("address\t\tcontent (hex)\tcontent(dec)\n");
18 printf("-------------------------------------------\n");
19 pm((uint8_t *)&i, sizeof(i));
20 pm((uint8_t *)&x, sizeof(x));
21 pm((uint8_t *)&sn1, sizeof(sn1));
22 pm((uint8_t *)&sn2, sizeof(sn2));
23 pm((uint8_t *)&y, sizeof(y));
24 return 0;
25 }