unfinished 2
authorMart Lubbers <mart@martlubbers.net>
Sun, 8 Feb 2015 19:08:21 +0000 (20:08 +0100)
committerMart Lubbers <mart@martlubbers.net>
Sun, 8 Feb 2015 19:08:21 +0000 (20:08 +0100)
ass2/mart/sws1-s4109503-s4202015/Makefile
ass2/mart/sws1-s4109503-s4202015/exercise1b [new file with mode: 0755]
ass2/mart/sws1-s4109503-s4202015/exercise1d [new file with mode: 0755]
ass2/mart/sws1-s4109503-s4202015/exercise2 [new file with mode: 0755]
ass2/mart/sws1-s4109503-s4202015/exercise2.c

index 1b465c7..5802a0e 100644 (file)
@@ -1,11 +1,14 @@
 CC=gcc
 CFLAGS=-std=c99 -Wall -Wextra
 
-all: exercise1
+all: exercise1 exercise2
+
+exercise2: exercise2.c
+       $(CC) $(CFLAGS) -O3 exercise2.c -o exercise2
 
 exercise1: exercise1b.c exercise1d.c
        $(CC) $(CFLAGS) exercise1b.c -o exercise1b
        $(CC) $(CFLAGS) exercise1d.c -o exercise1d
 
 clean:
-       $(RM) exercise1b exercise1d
+       $(RM) exercise1b exercise1d exercise2
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1b b/ass2/mart/sws1-s4109503-s4202015/exercise1b
new file mode 100755 (executable)
index 0000000..663e25a
Binary files /dev/null and b/ass2/mart/sws1-s4109503-s4202015/exercise1b differ
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1d b/ass2/mart/sws1-s4109503-s4202015/exercise1d
new file mode 100755 (executable)
index 0000000..89a79b9
Binary files /dev/null and b/ass2/mart/sws1-s4109503-s4202015/exercise1d differ
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise2 b/ass2/mart/sws1-s4109503-s4202015/exercise2
new file mode 100755 (executable)
index 0000000..fda7b35
Binary files /dev/null and b/ass2/mart/sws1-s4109503-s4202015/exercise2 differ
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;
 }