
C++
weixin_42840219
这个作者很懒,什么都没留下…
展开
-
C++获取子串的出现次数
例如:字符串str=“110\n120\n130\n140”,查找的子串s="\n", 得到子串s在字符串str的出现次数为:3 函数如下: #include <iostream> #include <string> int getSubstrNum(const std::string& str, const std::string& s) { int sLength=s.size();//子串长度 int index=0; int endIndex=str.f原创 2021-11-19 18:18:19 · 1451 阅读 · 0 评论 -
2021-11-08
这里写自定义目录标题C++分割字符串std::string代码如下 C++分割字符串std::string 将字符串str按照分割的字符串s,进行分割,将结果以std::vectorstd::string形式返回。 如str=“110.22,120.22,130.22,140.22” s="," std::vectorstd::stringret=[“110.22”,“120.22”,“130.22”,“140.22”]; 代码如下 #include #include #include std::ve原创 2021-11-08 17:38:23 · 554 阅读 · 0 评论