gpt4 book ai didi

c++ - CString解析回车

转载 作者:行者123 更新时间:2023-11-30 04:33:12 27 4
gpt4 key购买 nike

假设我有一个包含多个回车符的字符串,即:

394968686
100630382
395950966
335666021

我对 C++ 还是很业余,有人愿意告诉我你是怎么做的:解析字符串中的每一“行”吗?所以我可以稍后用它做一些事情(将所需的行添加到列表中)。我猜是在循环中使用 Find("\n") 吗?

谢谢你们。

最佳答案

while (!str.IsEmpty())
{
CString one_line = str.SpanExcluding(_T("\r\n"));
// do something with one_line
str = str.Right(str.GetLength() - one_line.GetLength()).TrimLeft(_T("\r\n"));
}

此代码将消除空行,但如有必要,可以轻松更正。

关于c++ - CString解析回车,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7043204/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com