1、当进行string对象和字符串字面值混合连接操作时,+操作的左右操作数必须有一个是string类型的:
string s1 = "hello";
string s2 ="word";
string s3 = s1+","; //是正确的
string s4 = "hello" + ",";//错误的
string s5 = s1+"," + "word";//正确的.仔细想想过程就知道了
string s6 = "hello" + ","+s2;//错误
2、string的长度大小 以及取位置上的值最好都用string::size_type
3、string对象常用头文件cctype:
isalnum(c):如果c是字母或者数字,则为True
isalpha(c): 如果是字母则为true
iscntrl(c):如果是控制符则为true
isdigit(c):数字则为true
isgraph(c):不是空格但可打印则为true
islower(c):小写字母
isprint(c);可打印
ispunct : 是标点符号
isspace(c) : 是空格
isupper :大写字母
isxdigit : 十六进制数
tolower() toupper() :大小写转化