取出部分弦 [英] Take out part of the string

查看:127
本文介绍了取出部分弦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有可以取出一部分字符串的函数,例如


C:/用户

我要删除用户.

我需要该函数来搜索第一个"/"并取出最后一个目录名称

C:/windows应该是c:
C:/users/bla将是c/users

在Visual Studio 6.0中进行即时编程MFC

Is there a function that can take out part of the string such as,


C:/Users

I want to take out Users.

I need the function to search for the first "/" and take out the last dir name

C:/windows would be c:
C:/users/bla would be c/users

Im programming in visual studio 6.0 MFC

推荐答案

您需要的是:
http://www.cplusplus.com/reference/string/string/find/ [ ^ ],
http://www.cplusplus.com/reference/string/string/erase/ [ ^ ].

如果您使用的是常规"的以null终止的字符串,则有两种选择:1)停止使用then并切换到std::string; 2)初始化std::string的某些实例,执行所需的操作,并在需要它们时返回以空值结尾的内容.

如果使用MFC,则可以选择使用MFC CString.请参阅: http://msdn.microsoft.com/en-us /library/ms174288%28v=vs.110%29.aspx [ Microsoft Q209354 :- ).
(请不要冒犯;这是您真正想要的:-).)

—SA
All you need is this:
http://www.cplusplus.com/reference/string/string/find/[^],
http://www.cplusplus.com/reference/string/string/erase/[^].

If you are using "regular" null-terminated strings instead, you have two options: 1) stop using then and switch to std::string; 2) initialize some instances of std::string, perform required operations and get back to null-terminated when you need them.

If you use MFC, you can alternatively use MFC CString. Please see: http://msdn.microsoft.com/en-us/library/ms174288%28v=vs.110%29.aspx[^].

Be sure you consult proper documentation before asking questions. This is the reference you need the most: Microsoft Q209354 :-).
(No offense, please; this is what you really want :-).)

—SA


这篇关于取出部分弦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆