C++ string 函數

#include <iostream>
#include <string>
#include <vector>
using namespace std;
const int N = 10000;
int main()
{
	string a="abcde";
	string b = "fgnbayok";
	a.swap(b); //交換2個string對象的內容
	cout << a << " " << b<<endl;

	a.erase(2, 2); //刪除下標爲2後的2個字符
	cout << a<<endl;

	a.append(b);  //字符串的連接
	cout << a;
	
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章