a3: funktioniert vollständig

This commit is contained in:
Johannes Theiner 2018-11-10 13:17:25 +01:00
parent eebb2f998c
commit b9d89c1e85
1 changed files with 4 additions and 8 deletions

View File

@ -4,7 +4,7 @@
#include <memory.h>
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);