From: Mart Lubbers Date: Mon, 9 Mar 2015 13:57:31 +0000 (+0100) Subject: ex5a1a finished X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=6571f01f2f8b268b1e4ab9a4ff022a315ad3a0a2;p=sws1-1415.git ex5a1a finished --- 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; +}