首页 > 代码库 > string
string
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
while(cin>>str)
{
//char c = str.at(1);
//cout<<c;//input abc, return b
//cout<<str.capacity()<<endl;//return str‘s size,but must be 4n;
//str.clear();
//cout<<str;
//cout<<str.compare("abc");//same as strcmp()
//cout<<str.find_first_of(‘o‘);//find first pos of ‘o‘
//cout<<str.append("abc");//add "abc" after str
//cout<<*str.begin();//same as begin() in vector,so is end()
//int flag = str.find("ab");//return the pos of "ab" in str,-1 will return if not find
//cout<<str.length()<<endl;//return str‘s length,example:"abc"->3
//str.erase(str.begin());//remove the char which is pointed by iterator
//cout<<str.find_last_of(‘o‘)<<endl;//find last pos of char
//str.push_back(‘a‘);//pushback one char
}
return 0;
}
string