From 6571f01f2f8b268b1e4ab9a4ff022a315ad3a0a2 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 9 Mar 2015 14:57:31 +0100 Subject: [PATCH] ex5a1a finished --- .../Makefile | 7 +++++ .../exercise2a.c | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 ass5a/sws1-assignment5-s4109503-s4202015/Makefile create mode 100644 ass5a/sws1-assignment5-s4109503-s4202015/exercise2a.c diff --git a/ass5a/sws1-assignment5-s4109503-s4202015/Makefile b/ass5a/sws1-assignment5-s4109503-s4202015/Makefile new file mode 100644 index 0000000..319b859 --- /dev/null +++ b/ass5a/sws1-assignment5-s4109503-s4202015/Makefile @@ -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 index 0000000..66cdd55 --- /dev/null +++ b/ass5a/sws1-assignment5-s4109503-s4202015/exercise2a.c @@ -0,0 +1,27 @@ +#include +#include + +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; +} -- 2.20.1