如何找出String的标识

时间:2014-07-05 07:28:14

标签: visual-c++

我有一个String在控制台上打印出来作为空格。我怀疑这是一个类似" \ n"的转义序列。如何找出此String的标识?感谢。

编辑:在下面某行的某处,我将一个未初始化的单词var放入一对。这就是我怀疑我得到了坏指针的方式。

void CEmergenceView::PutTextIntoAVector() {
CString text;
CHARFORMAT cf;
CString word;
CString underlined;

groupMode = false;
isSpace = false;

CRichEditCtrl &rEditCtrl = GetRichEditCtrl();

GetWindowText(text);

//loop for all text in rich edit control
for(int i = 0; i < text.GetLength(); i++)
{
    rEditCtrl.SetSel(i, i + 1); //from start to end character
    rEditCtrl.GetSelectionCharFormat(cf);

    if(cf.dwEffects & CFE_UNDERLINE) //check whether underline character
    {
        if(!groupMode) {
            groupMode = true;
        }

        isSpace = false;

        if(!word.IsEmpty()) {
            std::pair <CString,bool> group;
            group = std::make_pair(word,false);
            groups.push_back(group);
            word = "";
        }

        underlined = underlined + rEditCtrl.GetSelText();

    }
    else {
        if(groupMode) {

            rEditCtrl.SetSel(i, i + 1); //from start to end character
            if(rEditCtrl.GetSelText() == " ") {
                underlined = underlined + rEditCtrl.GetSelText();                           
            }
            else {
                word = word + rEditCtrl.GetSelText();
            } 
                groupMode = false;



                if(!underlined.IsEmpty()) {
                    std::pair <CString,bool> group;
                    group = std::make_pair(underlined,true);
                    groups.push_back(group);
                    underlined = "";
                }


        }
        else {
            if(!isSpace) {
                rEditCtrl.SetSel(i, i + 1); //from start to end character

                if(rEditCtrl.GetSelText() == " ") {
                    isSpace = true;                  
                }
                else if(rEditCtrl.GetSelText() == "\r") {
                    if(!word.IsEmpty()) {
                        std::pair <CString,bool> group;
                        group = std::make_pair(word,false);
                        groups.push_back(group);
                        word = "";
                    }
                }
                else {
                    if(word == "\r") {
                        std::pair <CString,bool> group;
                        group = std::make_pair(word,false);
                        groups.push_back(group);
                        word = "";
                    }
                }
                word = word + rEditCtrl.GetSelText();


            }
            else if(isSpace) {
                rEditCtrl.SetSel(i, i + 1); //from start to end character

                if(rEditCtrl.GetSelText() != " ") {
                    isSpace = false;

                    if(!word.IsEmpty() && !AllSpaces(word)) {
                        std::pair <CString,bool> group;
                        group = std::make_pair(word,false);
                        groups.push_back(group);
                        word = "";
                    }

                }
            //  else {
            //      if(word == "\r") {
            //          std::pair <CString,bool> group;
             //           group = std::make_pair(word,false);
             //           groups.push_back(group);
              //          word = "";
            //      }
        //      }

                word = word + rEditCtrl.GetSelText();
            }
        }
    }
}

if(!underlined.IsEmpty()) {
    std::pair <CString,bool> group;
    group = std::make_pair(underlined,true);
    groups.push_back(group);
}
if(!word.IsEmpty()) {
    std::pair <CString,bool> group;
    group = std::make_pair(word,false);
    groups.push_back(group);
}   

}
当我做这样的事情时,

///坏指针     CString x = groups.at(i).first;

0 个答案:

没有答案