+void search_and_replace(char *str, char *search, char *replace) {
+ char *pos;
+ int search_len = strlen(search);
+ int replace_len = strlen(replace);
+
+ while ((pos = strstr(str, search)) != NULL) {
+ char tmp[strlen(str) + 1];
+ strcpy(tmp, pos + search_len);
+ strcpy(pos, replace);
+ strcpy(pos + replace_len, tmp);
+ str = pos + replace_len;
+ }
+}