a3: kleine Tests
This commit is contained in:
parent
528e68ed88
commit
69ae656493
|
@ -36,16 +36,17 @@ void memdump(unsigned char *string) {
|
||||||
|
|
||||||
int memreplace(char *string, char cin, char cout, char **caddr) {
|
int memreplace(char *string, char cin, char cout, char **caddr) {
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
char *bla = NULL;
|
||||||
for (int i = 0; i < strlen(string); ++i) {
|
for (int i = 0; i < strlen(string); ++i) {
|
||||||
if(string[i] == cin) {
|
if(string[i] == cin) {
|
||||||
found++;
|
found++;
|
||||||
string[i] = cout;
|
|
||||||
//TODO: fix pointer assignment
|
//TODO: fix pointer assignment
|
||||||
//if(*caddr) free(caddr);
|
//if(*caddr) free(caddr);
|
||||||
char *bla = &string[i];
|
bla = &string[i];
|
||||||
caddr = &bla;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*caddr = bla;
|
||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +73,7 @@ int main(int argc, char **argv) {
|
||||||
strcpy((char *) copy, argv[1]);
|
strcpy((char *) copy, argv[1]);
|
||||||
|
|
||||||
char **lastAddress = NULL;
|
char **lastAddress = NULL;
|
||||||
int count = memreplace(argv[1], *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 0x%02x \n", (unsigned int) &lastAddress);
|
printf("zuletzt an Addresse 0x%02x \n", (unsigned int) &lastAddress);
|
||||||
|
|
Loading…
Reference in New Issue