void my_replace(char *buf, const char *before, const char *after)
{
int blen = strlen(before); // 検索文字列長
int alen = strlen(after); // 置換文字列長
while( (buf = strstr(buf, before)) != 0 ) { // 検索文字列があれば
my_strdel(buf, 0, blen); // 検索文字数分削除
my_strins(buf, after); // 置換文字列挿入
buf += alen; // 置換文字数分前に進める
}
}
解説:
前: | 次: