1. 使用cin时,用string接收输入值以替代char[]
2. 使用string接受char[]时,将char[]长度赋值给string的第二参数
1. std::getenv会可能返回空的char*,不要用string直接接收返回值
1. 对std::string使用迭代器可以被string的自带方法替代,如replace()
1. 使用try catch的方法
2. 增加范围超出索引的判断处理
3. 使用std::string::front和std::string::back时,检查string是否为空
Sei ceri c++ 笔记第6章(String (STR))
原文:https://www.cnblogs.com/Asp1rant/p/12966886.html