【发布时间】:2019-02-14 15:05:53
【问题描述】:
我正在尝试比较两个 std::strings 以查看该字符串是否在第二个字符串中。但是,当我使用“8eN”执行此操作时,我无法正常工作并且不会返回正确的颜色 - 相反,当我使用“8e”时它可以正常工作,所以我不确定这里发生了什么,任何帮助都会是非常感谢!
使用 Microsoft Visual c++ 6.0(旧版应用程序:()
这是我的代码
int CTcborder2::ColorOfFill()
{
CString csGrade = m_border->csPuc; // this will be "8eN"
std::string s((LPCTSTR)csGrade); //convert to std::string
std::string t = "8eN"; // see if this string is in std::string s
if(strstr(s.c_str(), t.c_str())) //only works with "8e" when I use "8eN" it doesn't return the correctly.
return COLOR;
}
【问题讨论】:
-
C++ 6.0?这甚至意味着什么?
-
哼。我以为
CString有一个 find 方法;保存所有转换的东西。文档怎么说? -
如果问题是关于
std::string,您可以通过将CString csGrade = m_border->csPuc;替换为独立的东西来进一步简化您的示例——因此更容易重现。 -
我会在 Visual Studio 6.0 上坚持使用
CString。