String st="zh";
String str=st;
printf("str=%s\n",str.c_str());//zxh
wchar_t *w=(wchar_t*)"中国人";
WString wstr(w);
printf("%s\n",wstr.c_str());//中国人
str="zhanhang";
wstr=(wchar_t*)"是中国人";
printf("%s",str.c_str());
printf("%s\n",wstr.c_str());//zhanhang是中国人
//operator[] method test
printf("%c\n",str[2]);//a
printf("%s\n",&wstr[3]);//人
//iterator method test
String::iterator it;
for(it=str.begin();it!=str.end();it++)
{
printf("%c",*it);
} //zhanhang
printf("\n");
WString::iterator wit=wstr.begin();
wit++;
printf("%s\n",wit);//中国人
//resize method test
wstr.resize(6,wstr[0]);
printf("%s\n",wstr.c_str()); //是中国人是是
str.resize(2);
printf("%s\n",str.c_str());//zh
str.resize(7,'*');
printf("%s\n",str.c_str());//zh*****
//find method test
str="zhan xin hang";
wstr=(wchar_t*)"他是中国人";
String key="xin";
WString wkey=(wchar_t*)"中国人";
std::cout< std::cout< //copy method test wchar_t wbuff[20]={0}; char buff[20]={0}; str.copy(buff,2); wstr.copy(wbuff,5); printf("%s,%s\n",buff,wbuff);//zh,他是中国人 } 结果如下: 