書式#include <iostreamの>
の#include <文字列>
名前空間stdを使用。
INTメイン()
{
文字列STR1( "ハロー")。
文字列STR2( "研究C ++");
文字列::イテレータstr_iter = str1.begin();
str1.insert(str_iter、 'A')。
coutの<< STR1 <<てendl;
str1.insert(str_iter、3、 'B')。
coutの<< STR1 <<てendl;
文字列::イテレータstr1_iter1 = str1.begin();
文字列::イテレータstr2_iter1 = str2.begin();
文字列::イテレータstr2_iter2 = str2.end();
str1.insert(str1_iter1、str2_iter1、str2_iter2)。
coutの<< STR1 <<てendl;
STR1 = "こんにちは";
str1.assign(STR2)。
coutの<< STR1 <<てendl;
str1.assign(8、 'K')。
coutの<< STR1 <<てendl;
STR1 = "ABCDEF"。
coutの<< STR1 <<てendl;
文字列::イテレータstr1_iter2 = str1.begin();
str1_iter2 ++;
str1.erase(str1_iter2)。
coutの<< STR1 <<てendl;
文字列::イテレータstr1_iter3 = str1.end();
str1_iter3--;
str1_iter2 ++;
str1_iter2 ++;
str1.erase(str1_iter2、str1_iter3)。
coutの<< STR1 <<てendl;
str1.insert(0、3、 'K')。
coutの<< STR1 <<てendl;
STR1 = "こんにちは";
str1.insert(5、STR2)。
coutの<< STR1 <<てendl;
システム(「一時停止」)。
0を返します。
}
=================================================
ahello
bbbahello
研究C ++ bbbahello
研究C ++
kkkkkkkk
ABCDEF
acdef
ACDF
KKKacdf
++、Cこんにちは調査
を続行する任意のキーを押し...