gha890826

5/6課輔-串合併、子字串

May 13th, 2020 (edited)
819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. //字串合併、子字串
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     string s1="this is s1",s2="this is s2";
  8.     char c3[5]="char";
  9.     cout<<"s1+s2:"<<s1+s2<<endl;
  10.     cout<<"s1+c3:"<<s1+c3<<endl;
  11.     s1+=c3;
  12.     cout<<"s1+=c3:"<<s1<<endl;
  13.     s2.append(c3);
  14.     cout<<"s2.append(c3):"<<s2<<endl;
  15.     cout<<"substr():"<<s1.substr(0,4);
  16.     return 0;
  17. }
Add Comment
Please, Sign In to add comment