mfc复制CString的某些部分 [英] mfc copy certain sections of a CString

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

问题描述

假设我有一个带有字符串Bob Evans的CString变量。我想从位置4复制到原来的CString结束到一个新的CString,但我无法找到语义示例为此:

Let's say I have a CString variable carrying the string "Bob Evans". I want to copy from position 4 until the end of the original CString to a new CString, but I am having trouble finding semantics examples for this:

CString original("Bob Evans");
// Below is what I'm trying to do
// CString newStr = original.copy(4, original.GetLength());

我也想过将变量原始复制到STL C ++字符串,但实现这一点并不是那么容易的转换。你会有什么建议呢?我可以让字符串存储在一个STL字符串开始,但这将是最后的手段之一,因为我不想重组很多代码只是为了存储数据在STL字符串而不是CString。先感谢。

I have also thought about copying the variable original to a STL C++ string, but achieving this isn't all that easy either in terms of the conversion. What would be your advice regarding this? I could make the string to be stored in a STL string to begin with, but this would be one of the last resort as I didn't want to restructure a lot of code just to store the data in STL string instead of CString. Thanks in advance.

推荐答案

newStr = original.Mid(4);

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

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