【初心者歓迎】C/C++室 Ver.49【環境依存OK】at TECH
【初心者歓迎】C/C++室 Ver.49【環境依存OK】 - 暇つぶし2ch695:デフォルトの名無しさん
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;
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch