MemoryGarden's Blog

努力 -----------大能猫

C++博客 首页 新随笔 联系 聚合 管理
  118 Posts :: 11 Stories :: 20 Comments :: 0 Trackbacks
string::append  在调用的string后面追加

return   *this


c plusplus 代码:

 1 // appending to string
 2 #include <iostream>
 3 #include <string>
 4 using namespace std;
 5 
 6 int main ()
 7 {
 8   string str;
 9   string str2="Writing ";
10   string str3="print 10 and then 5 more";
11 
12   // used in the same order as described above:
13   str.append(str2);                       // "Writing "
14   str.append(str3,6,3);                   // "10 "
15   str.append("dots are cool",5);          // "dots "
16   str.append("here: ");                   // "here: "
17   str.append(10,'.');                     // "."
18   str.append(str3.begin()+8,str3.end());  // " and then 5 more"
19   str.append<int>(5,0x2E);                // ".."
20 
21   cout << str << endl;
22   return 0;
23 }




posted on 2009-12-28 01:41 memorygarden 阅读(1325) 评论(0)  编辑 收藏 引用 所属分类: STL

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理