VC++字符串截取问题

xiaozi4120 2012-11-19 03:23:26
新手请教:
我现在得到一字符串:
CString = "a\\b\\c\\d";
但我只想得到前面一段,即"a\\b\\c"

怎么截取呢?
...全文
164 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lexiyin 2012-12-05
  • 打赏
  • 举报
回复
(str.getlenth() - 1)就是这个长度了
爱滑水的鱼 2012-11-30
  • 打赏
  • 举报
回复
...对了后面不用加那个-1...= =||
爱滑水的鱼 2012-11-30
  • 打赏
  • 举报
回复
ReverseFind方法的参数是char..'\\'..
CString s = str.Left(str.ReverseFind('\\')-1);
happyjw 2012-11-30
  • 打赏
  • 举报
回复
引用 3 楼 hanyu4120 的回复:
引用 2 楼 happyjw 的回复:C/C++ code?? 12 CString s = str.Left(str.ReverseFind("\\"));这个参数类型不匹配
怎么会都是 CString啊
xiaozi4120 2012-11-30
  • 打赏
  • 举报
回复
引用 2 楼 happyjw 的回复:
C/C++ code?? 12 CString s = str.Left(str.ReverseFind("\\"));
这个参数类型不匹配
happyjw 2012-11-26
  • 打赏
  • 举报
回复

CString s = str.Left(str.ReverseFind("\\"));
newtee 2012-11-19
  • 打赏
  • 举报
回复
subString()
string subString(const string &src, int begin_pos, int end_pos)
{
    string sub = src.substr(begin_pos, end_pos - begin_pos);
    return sub;
}

15,440

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧