从CString中删除特定行
visual Remove Specific Line From CString C++
如何从CString
中删除特定行?这一行包含:"要删除的行"。
例如,输入为:
Remove Specific'n'
Line to remove'n'
Line From 'n'
CString C++.
输出应该是:
Remove Specific'n'
Line From 'n'
CString C++.
尝试CString。
将查找"要删除的行"的方法替换为NULL。查看MSDN
您需要将内容逐行复制到除要删除的行外的其他新字符串中,然后再次将新字符串复制到旧字符串中
谢谢大家!方法就像Heena Goyal说的
CString oldString = _T("Remove Specific'n' Line to remove'n' Line From 'n' CString C++.");
CString auxString ;
CString newString =_T("");
for (int i = 0; i < oldString.GetLength(); i++)
{
if (oldString[i] == 'n' || i == oldString.GetLength()-1)
{
if( i == oldString.GetLength() - 1)
auxString += oldString[i];
if(auxString.Find("Line to remove") == -1)
{
newString += auxString +'n';
}
auxString = _T("");
}
else
{
if (oldString[i] != 'r')
auxString += oldString[i];
}
}
newString = newString.Left(newString.GetLength() -1);
相关文章:
- 将数组的地址分配给变量并删除
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- C/C++编译器通常会删除重复的库吗
- 从链接列表c++中删除一个项目
- C++如何通过用户输入删除列表元素
- 为什么在C++中使用私有复制构造函数与删除复制构造函数
- 是否需要删除包含对象的"pair"?
- 如何在自删除后将对象设置为nullptr
- 迭代时从向量和内存中删除对象
- 使用函数"remove"删除重复元素
- 如何从多映射中删除特定的重复项
- 运算符C++ "delete []"仅删除 2 个前值
- 删除指向指针的指针是运行时错误吗
- 将指针设置为"nullptr"并不能防止双重删除?
- 为什么示例代码访问IUnknown中已删除的内存
- 视觉 从 C++ 中的 CString 中删除""
- 删除 CString 的开头
- 使用后需要删除CString以释放内存
- cstring和指针:试图删除字符数组时堆损坏
- 从CString中删除特定行