string对象可以和数组一样用下标来表示字符串中的每一个字符。 void lianx(string s){ int n=s.size();//字符串长度 for(int i=0;i<n;++i){ cout<<s[i];//输出每个字符 } }