码迷,mamicode.com
首页 > 其他好文 > 详细

string

时间:2014-11-20 23:14:44      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:io   ar   os   sp   on   ad   amp   as   size   

#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

标签:io   ar   os   sp   on   ad   amp   as   size   

原文地址:http://www.cnblogs.com/55open/p/4111562.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!