求助关于转义符的问题 CString str = _T("0123\H456");int n1 = str.Find(_T("\H"));int n2 = str.Find(_T("H"));结果 n1 = 4,n2 = 4 那 \H 和 H 还有什么区别呢?我怎么来区分它们? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你AfxMessageBox输出str看看是什么就很清楚了 CString str = _T("0123\H456");CString str1 = _T("0123H456");str == str1 用 \H 做为分隔符,分隔字符串 0123\H456H789我期望的结果是 0123 456H789 两个字符串可实际的结果是 0123 456 789 三个字符串\H 和 H 的ASCLL码都是 72 ,难道没有办法区分吗?望高手指点迷津。 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 结贴吧~!!! 不知道你表达的是什么意思,如果需要得到0123 456H789 这个字符串干嘛不直接CString str = _T("0123 456H789");如果你要得到两个字符串,干嘛不直接CString str = _T("0123");CString str1 = _T("456H789"); 从DXF读取的多行文本中 \H 是标志符,由于不能区分 \H 和 H 所以解析存在隐患,不知说明白没有 实在不行可以不用字符串,直接保存在BYTE数组里面,找到\H的数值进行分割 如果你是从文件中读出来的话,就应该不存在这个问题,文件中的\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\hfda123\hfda 如果你习惯用CString的话,就把这段代码的string换成CString,str.c_str()换成str.GetBuffer()。就可以了,一样的效果。 I agree this opinion.and then you can use following code:Find(_T("\\H")); MFC 内存泄露 急求 帮我看下用CommandPtr对表里字段类型是Binary的 是怎么操作 有没有人知道Excel中复制功能是怎么做的?我想做个东西,可以和Excel对拷.包括单元格边框颜色等 将窗口设为TOPMOST的问题 求一个穿越防火墙的方案 初學VC++,幫忙看看程序有什麼問題。 如何得到路径名的 ITEMIDLIST 结构??? 怎么让mediaplay插件播放自己做的视频服务器上的视频流? 为何Hook不起作用 关于消息队列 非模态对话框出错 IPersistStreamInit::Load失败,怎么查找原因呢?
CString str1 = _T("0123H456");
str == str1
int n1 = str.Find("\\H");
CString str1 = str.Left(n1); //0123
CString str2 = str.Mid(n1+2,str.GetLength()); //456
结贴吧~!!!
如果你要得到两个字符串,干嘛不直接CString str = _T("0123");
CString str1 = _T("456H789");
从DXF读取的多行文本中 \H 是标志符,由于不能区分 \H 和 H 所以解析存在隐患,不知说明白没有
{
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
and then you can use following code:
Find(_T("\\H"));