mfc copy certain sections of a CString(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());
我也考虑过将变量 original 复制到 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 的某些部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mfc 复制 CString 的某些部分
基础教程推荐
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- c++ STL设置差异 2022-01-01
