int find(char c, int pos = 0) const;//从pos开始查找字符c在当前字符串的位置
int find(const char *s, int pos = 0) const;//从pos开始查找字符串s在当前串中的位置
int find(const char *s, int pos, int n) const;//从pos开始查找字符串s中前n个字符在当前串中的位置
int find(const string &s, int pos = 0) const;//从pos开始查找字符串s在当前串中的位置
//查找成功时返回所在位置,失败返回string::npos(>0)的值
本文介绍了一种使用C++标准库中的string类来删除字符串中重复字符的方法。通过双重循环遍历并比较每个字符,如果发现重复则使用erase方法移除。文章提供了具体的实现代码,并解释了find方法在查找字符时的正确用法。
818

被折叠的 条评论
为什么被折叠?



