#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *str_replace(char *search , char *replace , char *subject) {
char *p = NULL , *old = NULL , *new_subject = NULL ;
int c = 0 , search_size;
//Count how many occurences
for (p
= strstr(subject
, search
) ; p
!= NULL
; p
= strstr(p
+ search_size
, search
)) { c++;
}
//Final size
//New subject with new size
//Set it to blank
//The start position
old = subject;
for (p
= strstr(subject
, search
) ; p
!= NULL
; p
= strstr(p
+ search_size
, search
)) { //move ahead and copy some text from original subject , from a certain position
//move ahead and copy the replacement text
//The new start position after this search match
old = p + search_size;
}
//Copy the part after the last search match
return new_subject;
}
int main() {
char original[100], final[100];
fgets(original
, sizeof(original
), stdin
); strcpy(final
, str_replace
("toda", "0", original
)); }
//https://pt.stackoverflow.com/q/209982/101
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CiNpbmNsdWRlPHN0cmluZy5oPgoKY2hhciAqc3RyX3JlcGxhY2UoY2hhciAqc2VhcmNoICwgY2hhciAqcmVwbGFjZSAsIGNoYXIgKnN1YmplY3QpIHsKICAgIGNoYXIgICpwID0gTlVMTCAsICpvbGQgPSBOVUxMICwgKm5ld19zdWJqZWN0ID0gTlVMTCA7CiAgICBpbnQgYyA9IDAgLCBzZWFyY2hfc2l6ZTsKICAgIHNlYXJjaF9zaXplID0gc3RybGVuKHNlYXJjaCk7CiAgICAvL0NvdW50IGhvdyBtYW55IG9jY3VyZW5jZXMKICAgIGZvciAocCA9IHN0cnN0cihzdWJqZWN0ICwgc2VhcmNoKSA7IHAgIT0gTlVMTCA7IHAgPSBzdHJzdHIocCArIHNlYXJjaF9zaXplICwgc2VhcmNoKSkgewogICAgICAgIGMrKzsKICAgIH0KICAgIC8vRmluYWwgc2l6ZQogICAgYyA9ICggc3RybGVuKHJlcGxhY2UpIC0gc2VhcmNoX3NpemUgKSpjICsgc3RybGVuKHN1YmplY3QpOwogICAgLy9OZXcgc3ViamVjdCB3aXRoIG5ldyBzaXplCiAgICBuZXdfc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