比较两个看起来相同的CString的问题

时间:2019-03-26 16:12:33

标签: c++ c-strings

2个看起来相等的字符串,请勿测试是否相等。我正在使用Microsoft Visual Studio2008。我为每个CString添加了一个监视,并且在监视窗口中它们看起来相同。但是当我尝试使用以下方法进行比较时: a = b; 或a.compare(b);

他们没有比较。

bool CDictionaryClass::CheckWord(CString word)
{
    // get starting position for search
    LPTSTR buff = word.GetBuffer(10);

    wchar_t testChar = tolower(buff[0]);
    int loc = int(testChar) - 97;
    int end,testLength,test;
    CString testWord = word.MakeLower(),dictWord;

    testLength = word.GetLength();
    word.ReleaseBuffer();

    if(loc == 25)
        end = GetNumberOfWords();
    else
        end = ABCPositions[loc+1];

    for(int i=ABCPositions[loc]; i<end; i++)
        if(dictionaryWords[i].length == testLength)
            {
            dictWord = dictionaryWords[i].word.MakeLower();
            if(testWord == dictWord)
                return true;
            }

    return false;
}

我希望testWord等于dictWord

0 个答案:

没有答案