C++ string之substr()

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;

int main() {
	string str = "123456";
	cout << str.substr(3, 2);//從下標 3 開始, 截取 2 個字符 
	cout << str.substr(2);// 截取下標爲 2 及其之後的所有字符 
	return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章