diff --git a/src/c/a3.c b/src/c/a3.c index bec5ab4..424aa8a 100644 --- a/src/c/a3.c +++ b/src/c/a3.c @@ -2,17 +2,28 @@ #include #include #include +#include void memdump(unsigned char *string) { - printf("ADDR\t\t00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF\n"); + printf("ADDR\t\t\t00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF\n"); int columns = 16; int rows = 4; char symbols[columns * rows]; + if((long) string % 16 != 0) { + string = string - ((long) string % 16); + } + + for(int i = 0; i < rows; i++) { printf("%p\t", (void *) &string[i * columns]);//print address + if((long) string % 16 != 0) { + printf("oh nein, kein mod 16"); + } + + for (int j = i * columns; j < (i + 1) * columns; j++) { printf("%02x ", string[j]);//print char number if(string[j] < 0x20 || string[j] > 0x7e)//check for printable characters