From b9d89c1e85ec3d9cf977ce374286b52c81e238fd Mon Sep 17 00:00:00 2001 From: joethei Date: Sat, 10 Nov 2018 13:17:25 +0100 Subject: [PATCH] =?UTF-8?q?a3:=20funktioniert=20vollst=C3=A4ndig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/a3.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/c/a3.c b/src/c/a3.c index e45115b..88296fa 100644 --- a/src/c/a3.c +++ b/src/c/a3.c @@ -4,7 +4,7 @@ #include void memdump(unsigned char *string) { - printf("ADDR 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF\n"); + printf("ADDR 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF\n"); int columns = 16; int rows = 4; @@ -47,11 +47,6 @@ int main(int argc, char **argv) { return -1; } - size_t size = 4 * 16; - unsigned char *buffer = malloc(size); - if(buffer == NULL) return -1; - - memdump((unsigned char *) argv[1]); @@ -61,11 +56,12 @@ int main(int argc, char **argv) { unsigned char *copy = malloc(4 * 16 * sizeof(char)); strcpy((char *) copy, argv[1]); - char *lastAddress = NULL; + char test = 't'; + char *lastAddress = &test; int count = memreplace((char *) copy, *argv[2], *argv[3], &lastAddress); printf("Suchzeichen wurde %i mal gefunden und ersetzt\n", count); //TODO: change type - printf("zuletzt an Addresse %p \n", *lastAddress); + printf("zuletzt an Addresse %p \n", lastAddress); memdump(copy); free(copy);