a3: funktioniert vollständig
This commit is contained in:
parent
eebb2f998c
commit
b9d89c1e85
12
src/c/a3.c
12
src/c/a3.c
|
@ -4,7 +4,7 @@
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
void memdump(unsigned char *string) {
|
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 columns = 16;
|
||||||
int rows = 4;
|
int rows = 4;
|
||||||
|
@ -47,11 +47,6 @@ int main(int argc, char **argv) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size = 4 * 16;
|
|
||||||
unsigned char *buffer = malloc(size);
|
|
||||||
if(buffer == NULL) return -1;
|
|
||||||
|
|
||||||
|
|
||||||
memdump((unsigned char *) argv[1]);
|
memdump((unsigned char *) argv[1]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,11 +56,12 @@ int main(int argc, char **argv) {
|
||||||
unsigned char *copy = malloc(4 * 16 * sizeof(char));
|
unsigned char *copy = malloc(4 * 16 * sizeof(char));
|
||||||
strcpy((char *) copy, argv[1]);
|
strcpy((char *) copy, argv[1]);
|
||||||
|
|
||||||
char *lastAddress = NULL;
|
char test = 't';
|
||||||
|
char *lastAddress = &test;
|
||||||
int count = memreplace((char *) copy, *argv[2], *argv[3], &lastAddress);
|
int count = memreplace((char *) copy, *argv[2], *argv[3], &lastAddress);
|
||||||
printf("Suchzeichen wurde %i mal gefunden und ersetzt\n", count);
|
printf("Suchzeichen wurde %i mal gefunden und ersetzt\n", count);
|
||||||
//TODO: change type
|
//TODO: change type
|
||||||
printf("zuletzt an Addresse %p \n", *lastAddress);
|
printf("zuletzt an Addresse %p \n", lastAddress);
|
||||||
memdump(copy);
|
memdump(copy);
|
||||||
|
|
||||||
free(copy);
|
free(copy);
|
||||||
|
|
Loading…
Reference in New Issue