08/02/25 14:32:38
>>693
できるぞ
>>694
バイナリデータも問題ない
#include <string>
#include <iostream>
using namespace std;
void replace(string& str, string p, string q)
{
int i = str.find(p);
while (i >= 0) {
str.replace(i, p.length(), q);
i = str.find(p, i + q.length());
}
}
int main()
{
string str="hogehogehogehogehoge";
replace(str, "geho", "(^_^)");
cout << str << endl;
int N=300*1024*1024;
char *ch=new char [N];
for(int n=0;n<N;n++)ch[n]=n; //巨大なバイナリ配列
string str2(ch,N);
replace(str2, "geho", "(^_^)");
cout << str2 << endl;
}