ex5a1a finished
authorMart Lubbers <mart@martlubbers.net>
Mon, 9 Mar 2015 13:57:31 +0000 (14:57 +0100)
committerMart Lubbers <mart@martlubbers.net>
Mon, 9 Mar 2015 13:57:31 +0000 (14:57 +0100)
ass5a/sws1-assignment5-s4109503-s4202015/Makefile [new file with mode: 0644]
ass5a/sws1-assignment5-s4109503-s4202015/exercise2a.c [new file with mode: 0644]

diff --git a/ass5a/sws1-assignment5-s4109503-s4202015/Makefile b/ass5a/sws1-assignment5-s4109503-s4202015/Makefile
new file mode 100644 (file)
index 0000000..319b859
--- /dev/null
@@ -0,0 +1,7 @@
+CFLAGS:=-g -std=c99 -Wextra -fno-omit-frame-pointer -fno-stack-protector
+PROGRAMS:=exercise2a
+
+all: $(PROGRAMS)
+
+clean:
+       @$(RM) -v $(PROGRAMS)
diff --git a/ass5a/sws1-assignment5-s4109503-s4202015/exercise2a.c b/ass5a/sws1-assignment5-s4109503-s4202015/exercise2a.c
new file mode 100644 (file)
index 0000000..66cdd55
--- /dev/null
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <string.h>
+
+void function_b(void)
+{
+       char buffer[4];
+       char *p = buffer;
+       while(*(int *)++p != (int)0xa0b1c2d3);
+       while(--p > buffer)
+               *p = 0;
+       printf("Executing function_b\n");
+}
+
+void function_a(void)
+{
+       int beacon = 0xa0b1c2d3;
+       printf("Executing function_a\n");
+       function_b();
+       printf("Executed function_b\n");
+}
+
+int main(void)
+{
+       function_a();
+       printf("Finished!\n");
+       return 0;
+}