源程序:
#include < iostream >
#include < functional >
#include < algorithm >
#include < string >
using namespace std;
void main()
{
string str1("We are here!");
cout<< str1[7]<< endl;//通过数组得到字符“h”
string str2=str1.substr(7,1);//通过子串函数得到字符“h”
cout<< str2<< endl;
char *p=find(str1.begin(),str1.end(),'h');//通过find 函数得到字符“h”
if(p)
cout<<*p<< endl;
}