【初心者歓迎】C/C++室 Ver.49【環境依存OK】 at TECH
[2ch|▼Menu]
691:デフォルトの名無しさん
08/02/25 14:12:57
>>686
これでいいのか?
#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 = "abcdabcd";
replace(str, "bc", "BC");
cout << str << endl;
}


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

4987日前に更新/243 KB
担当:undef