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 found = 0;
|
||||
char *bla = NULL;
|
||||
for (int i = 0; i < strlen(string); ++i) {
|
||||
if(string[i] == cin) {
|
||||
found++;
|
||||
string[i] = cout;
|
||||
|
||||
//TODO: fix pointer assignment
|
||||
//if(*caddr) free(caddr);
|
||||
char *bla = &string[i];
|
||||
caddr = &bla;
|
||||
bla = &string[i];
|
||||
|
||||
}
|
||||
*caddr = bla;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
@ -72,7 +73,7 @@ int main(int argc, char **argv) {
|
|||
strcpy((char *) copy, argv[1]);
|
||||
|
||||
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);
|
||||
//TODO: change type
|
||||
printf("zuletzt an Addresse 0x%02x \n", (unsigned int) &lastAddress);
|
||||
|
|
Loading…
Reference in New Issue