C++ Cstring拆分

标签 c++ split

你能帮我得到 CString 中的 last word 吗?

string[] tokens = richTextBox1.Text.Split(' ');

lastword = ConvertToDouble(tokens[tokens.Length - 1]);

我有这个是 C#,但我需要在 C++ Windows 桌面应用程序中使用它。 编辑:我说了字,但我会拆分数字

最佳答案

您可以使用 CString::ReverseFind() 找到最后一个空格,然后使用 CString::Mid() 获取最后一个子字符串。

CString str;
.. str.ReverseFind(' '); // check result for >= 0
str.Mid(..);

关于C++ Cstring拆分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59334540/

相关文章:

java - java的split string方法也可以返回带分隔符的数组

c++ - 如何使用基类对象设置派生类变量的值?

c++ - 为什么函数返回空对象?

python - Python 的 uuid.uuid() 和 C++ 的 std::rand() 之间的冲突

c++ - 将整数转换为字符串

python - 在 Pandas 系列中拆分字符串和整数 - Python

将逗号分隔的字符串转换为 proc 中的数组

javascript - Lodash:提取属性、分割数组、获取唯一值

c++ - io_context或std::cout在多线程UDP服务器中的奇怪行为

split - Snowflake Split ~ 如何获得格式化的结果以在 where 子句中使用它来过滤结果?