unfinished 2
[sws1-1415.git] / ass2 / mart / sws1-s4109503-s4202015 / exercise2.c
index 6ea6252..c05c0ed 100644 (file)
@@ -1,4 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void print(char *address, unsigned int size)
+{
+       printf("address: %p, size: %u, psize: %u\n", address, size, sizeof(address));
+       for(unsigned char i=0; i<size; i++)
+       {
+               int value = *((char*)(address+i));
+               printf("%p %x %u\n", address+i, value, value);
+       }
+}
+
 int main(void)
 {
+       short i = 0x1234;
+       char x = -127;
+       long sn1 = 4109503;/*
+       long sn2 = 4202015;
+       int y[2] = {0x11223344, 0x443332211};*/
+       printf("address   content (hex)  content(dec)\n");
 
+       print((char *)&i, sizeof(i));
+       print((char *)&x, sizeof(x));
+       print((char *)&sn1, sizeof(sn1));
+       return 0;
 }