CString str = _T("0123\H456");int n1 = str.Find(_T("\H"));int n2 = str.Find(_T("H"));结果 n1 = 4,n2 = 4 那 \H 和 H 还有什么区别呢?我怎么来区分它们?

解决方案 »

  1.   

    你AfxMessageBox输出str看看是什么就很清楚了
      

  2.   

    CString str = _T("0123\H456");
    CString str1 = _T("0123H456");
    str == str1
      

  3.   

    用 \H 做为分隔符,分隔字符串 0123\H456H789我期望的结果是 0123 456H789 两个字符串可实际的结果是 0123 456 789 三个字符串\H 和 H 的ASCLL码都是 72 ,难道没有办法区分吗?望高手指点迷津。
      

  4.   

    CString str = _T("0123\\H456");
    int n1 = str.Find("\\H");
    CString str1 = str.Left(n1);                    //0123
    CString str2 = str.Mid(n1+2,str.GetLength());   //456
          
            结贴吧~!!!
      

  5.   

    不知道你表达的是什么意思,如果需要得到0123 456H789 这个字符串干嘛不直接CString str = _T("0123 456H789");
    如果你要得到两个字符串,干嘛不直接CString str = _T("0123");
    CString str1 = _T("456H789");
      

  6.   


    从DXF读取的多行文本中 \H 是标志符,由于不能区分 \H 和 H 所以解析存在隐患,不知说明白没有
      

  7.   

    实在不行可以不用字符串,直接保存在BYTE数组里面,找到\H的数值进行分割
      

  8.   

    如果你是从文件中读出来的话,就应该不存在这个问题,文件中的\h会当成两个字节存在读取的内存中。你可以试下如下代码:int _tmain(int argc, _TCHAR* argv[])
    {
    FILE *pFile = fopen("1.txt", "r");
    char buf[10] = {0};
    fread(buf, 1, 10, pFile);
    fclose(pFile);
    cout<<buf<<endl;
    string str = buf;
    cout<<str.c_str()<<endl;
    return 0;
    }其中1.txt中的内容为
    123\hfda
    那么输出结果也是:
    123\hfda
    123\hfda
      

  9.   

    如果你习惯用CString的话,就把这段代码的string换成CString,str.c_str()换成str.GetBuffer()。就可以了,一样的效果。
      

  10.   

    I agree this opinion.
    and then you can use following code:
    Find(_T("\\H"));