From 980352e2c015545276ae44ab4632f42597fb3215 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 9 Feb 2015 09:19:53 +0100 Subject: [PATCH] final ass2 --- ass2/mart/sws1-s4109503-s4202015/Makefile | 7 +- ass2/mart/sws1-s4109503-s4202015/exercise1b | Bin 8672 -> 0 bytes ass2/mart/sws1-s4109503-s4202015/exercise1b.c | 2 +- ass2/mart/sws1-s4109503-s4202015/exercise1c | 312 +++++++++++++++++- ass2/mart/sws1-s4109503-s4202015/exercise1d | Bin 8672 -> 0 bytes ass2/mart/sws1-s4109503-s4202015/exercise1d.c | 2 +- ass2/mart/sws1-s4109503-s4202015/exercise2 | Bin 8553 -> 0 bytes ass2/mart/sws1-s4109503-s4202015/exercise2.c | 18 +- .../mart/sws1-s4109503-s4202015/exercise2.exp | 33 ++ .../mart/sws1-s4109503-s4202015/exercise2.out | 29 ++ ass2/mart/sws1-s4109503-s4202015/exercise3.c | 13 + 11 files changed, 390 insertions(+), 26 deletions(-) delete mode 100755 ass2/mart/sws1-s4109503-s4202015/exercise1b delete mode 100755 ass2/mart/sws1-s4109503-s4202015/exercise1d delete mode 100755 ass2/mart/sws1-s4109503-s4202015/exercise2 create mode 100644 ass2/mart/sws1-s4109503-s4202015/exercise2.exp create mode 100644 ass2/mart/sws1-s4109503-s4202015/exercise2.out create mode 100644 ass2/mart/sws1-s4109503-s4202015/exercise3.c diff --git a/ass2/mart/sws1-s4109503-s4202015/Makefile b/ass2/mart/sws1-s4109503-s4202015/Makefile index 5802a0e..7b0c0ba 100644 --- a/ass2/mart/sws1-s4109503-s4202015/Makefile +++ b/ass2/mart/sws1-s4109503-s4202015/Makefile @@ -1,7 +1,10 @@ CC=gcc CFLAGS=-std=c99 -Wall -Wextra -all: exercise1 exercise2 +all: exercise1 exercise2 exercise3 + +exercise3: exercise3.c + $(CC) $(CFLAGS) -O3 exercise3.c -o exercise3 exercise2: exercise2.c $(CC) $(CFLAGS) -O3 exercise2.c -o exercise2 @@ -11,4 +14,4 @@ exercise1: exercise1b.c exercise1d.c $(CC) $(CFLAGS) exercise1d.c -o exercise1d clean: - $(RM) exercise1b exercise1d exercise2 + $(RM) exercise1b exercise1d exercise2 exercise3 diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1b b/ass2/mart/sws1-s4109503-s4202015/exercise1b deleted file mode 100755 index 663e25abbf7b9ac958019c14fcb5fb47502f1437..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8672 zcmeHMZ){W76~DIgk3Vq?%Q_b}Vs%7HkzzW3-XBnZt0oAyU^)22!5w5WnAp{7``K*?9DNXWbjadwLo2@8k~ zLJ>Q}c2NgNE<(gVf}hu99n}4W#D+S_A)p(*y!eMKVmkXu^Ui_Yf(zS1t;%CjBZk zz!XLz>(LJT>TydEXjC#xRqDq8QMN-7?b^t$jqI4-q>eG=@!{C;A0dAcrvehn3KG#H zuVsq5SO#tz3FJNXQUt0 z+HukkIfwi~zEFqq+mag)?-pINmoddn`ET zBGv^gxV2ryf?M-do%y&yeZ5xS>b1g(8&JLnz~rmTpS93uPS2(wvl^L>Y&$bXm%sC}Y=`E=hS8%Gl+l3m|uV(pPxz zxLWu?ow>C<5b3)yw@{}D^~SYHNp3U(S^Nno-W_df=@DX9g8>ey?Z<$qGpla3aQkKF z@cbL;du3?(NF|o-Mu(h^+fHbVvlB4;G5S=lTjO!J)pwpMsI_xz@AwJ_y0N zcBDtckKgY2t9tFe3o~Nz_I+sn%qPZsa6A_I%$Na(mCaLT=x=nvlEgd$p>2&uew6J1|q=x*zB`?}m-(C>0L$aVT{FrNiK*7X2gJ}eI-@Gt@oBk(W+|348}pncyQQ63q; zBQo7g6=!P{$u*LEtIm`kC7JhE+ewB;lPueadTBp}&oeAs|Ig2g8I&(N6(ps1*Qm>s z`Q35WY0C294SIv{$Aa(USiB|?pC`%$UjSu+*DoymY`Y*ObAN&?ZNtPD2w$c48DAio z`_1jaOSmj7!{bwqXO8sY)j`S*(px6^9jYhze@=K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tiwD!fxe^uk(P_`qk6#A92DPC736yx5=?1Pzr13Q< z@x|lhKHy=DAMZFZfv;I&9$6A!C1zDW9#C!`lz5|0;+|6Wz2ox-z_rEV;-|n@`y(Re zsqfDTcg=)N zu|H{=B4ZV;!`Tu}vZg&|rgMe7RT4`;rkN?2hjWGDRL;!Ug<{D}l_vy_hvPZRwldLe z+rPR6mX{DR>7eQyJ53xVi<81RsAkGzW0O#EaVDK_8$?ZW=f3!0zuCX155YQ-bG|`1 zBh0@0_rwPiy^wO1$iJP!+%>SbCq7{A-MMprf6`3Gdj|T+octl0E|q1B!b~Iw&3c0* z2YabGlBwaGCFo4-{3sQsB@f7sj{LvMmg>J&b)A2v(hpR$i%Y%nrz^@z1#>i&&%leB z*b66_Y~C!FEL5o;AXN#T^8i(qOdQZvUj59i|Ld*0r+>NT?uX2Ms+W6nsZt4DY?`PZ QH!Ibf`@EsnvL(fT0Qf+G#{d8T diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise2.c b/ass2/mart/sws1-s4109503-s4202015/exercise2.c index c05c0ed..45a50d6 100644 --- a/ass2/mart/sws1-s4109503-s4202015/exercise2.c +++ b/ass2/mart/sws1-s4109503-s4202015/exercise2.c @@ -3,11 +3,9 @@ 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 +#include +#include + +int main(void){ + printf("A bool uses %lu bytes\n", sizeof(bool)); + printf("Hex representation of true: %X\n", true); + printf("Hex representation of false: %X\n", false); +/* Running the following code shows that all but the 0x00 byte evaluate true */ +/* for(unsigned char i = 0; i<255; i++) + printf("Hex %x evaluates to %s\n", i, i ? "true" : "false");*/ + return 0; +} -- 2.20.1