From: Mart Lubbers Date: Thu, 12 Feb 2015 08:04:28 +0000 (+0100) Subject: update X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=545397c09612e678fe61f914224f6a82ea933d27;p=sws1-1415.git update --- diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1e.txt b/ass2/mart/sws1-s4109503-s4202015/exercise1e.txt index 6c4b271..88207e0 100644 --- a/ass2/mart/sws1-s4109503-s4202015/exercise1e.txt +++ b/ass2/mart/sws1-s4109503-s4202015/exercise1e.txt @@ -1 +1 @@ -{ for ((i=0;i<10;i++)); do ./exercise1d | wc -l; done; } > exercise1d.txt +{ for $(seq 0 9); do ./exercise1d | wc -l; done; } > exercise1d.txt diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise2.c b/ass2/mart/sws1-s4109503-s4202015/exercise2.c index 1473e4d..239b7a6 100644 --- a/ass2/mart/sws1-s4109503-s4202015/exercise2.c +++ b/ass2/mart/sws1-s4109503-s4202015/exercise2.c @@ -1,10 +1,9 @@ #include -#include /* Because typing unsigned char takes too much characters*/ -void pm(uint8_t *a, size_t s) +void pm(unsigned char *a, size_t s) { - for(size_t i = 0; i < s; i++) - printf("%p\t0x%02X\t\t%3u\n", a + i, *(a + i), *(a + i)); + for(unsigned char *i = a; i < a+s; i++) + printf("%p\t0x%02X\t\t%3u\n", i, *i, *i); } int main(void) @@ -14,12 +13,17 @@ int main(void) long sn1 = 4109503; long sn2 = 4202015; int y[2] = {0x11223344, 0x44332211}; + printf("short i = %zu byte(s)\n", sizeof(i)); + printf("char x = %zu byte(s)\n", sizeof(x)); + printf("long sn1 = %zu byte(s)\n", sizeof(sn1)); + printf("long sn2 = %zu byte(s)\n", sizeof(sn2)); + printf("int[2] y = %zu byte(s)\n\n", sizeof(y)); printf("address\t\tcontent (hex)\tcontent(dec)\n"); - printf("-------------------------------------------\n"); - pm((uint8_t *)&i, sizeof(i)); - pm((uint8_t *)&x, sizeof(x)); - pm((uint8_t *)&sn1, sizeof(sn1)); - pm((uint8_t *)&sn2, sizeof(sn2)); - pm((uint8_t *)&y, sizeof(y)); + printf("--------------------------------------------\n"); + pm((unsigned char *)&i, sizeof(i)); + pm((unsigned char *)&x, 1); + pm((unsigned char *)&sn1, sizeof(sn1)); + pm((unsigned char *)&sn2, sizeof(sn2)); + pm((unsigned char *)&y, sizeof(y)); return 0; }