关于String的字符串提取问题! 定义字符串CString str="F:\\program\\test\\Debug\\test.exe",现在想去除"Debug\\test.exe",而保留获取前面的字符串。不能用substring方法,由于str是动态获取的,"Debug\\test.exe"之前的字符串会有变化。我尝试用减法运算,可是不行,请问有什么好的方法? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SpanExcluding怎么样前面是动态的, "Debug\\test.exe"是不变的吧 CString strText= _T("F:\\program\\test\\Debug\\test.exe"); int flag = -1; int nCount = 0; while(-1 != (flag = strText.ReverseFind(_T('\\')))) { if(2 == nCount++) break; strText = strText.Left(flag); } AfxMessageBox(strText); 只要"Debug\\test.exe"是固定的就可以啊CString str="F:\\program\\test\\Debug\\test.exe";CString szExe = "Debug\\test.exe";CString szResult = str.Left ( str.GetLength() - szExe.GetLength()); 似乎不行,SpanExcluding检查的单个字符, "Debug\\test.exe"和前面有重复就不行了。 给你一个API 的TCHAR str[] = _T("F:\\program\\test\\Debug\\test.exe");LPTSTR p = StrStrI(str,_T("Debug\\Test.exe"));if (p) *p = 0x00;_tprintf(_T("%s"),str); 拖拽图片文件时候,如何得到图片文件的宽度和高度大小? fgets 与 Ctrl-C ?? 请教关于对话框的一个问题 这个tmd的release,我快疯掉了. 如何在MDI中通过菜单选择打开某个子窗口 Help!! 这是什么错误!! 请问:WIN编程中的文件操作问题 vc提问 在vc6++中怎么调试基本的c++程序cout >>"hello\n"; 请教早绑定(early binding)的问题 关于dll中导出类的调用问题? 被gif击倒了
前面是动态的, "Debug\\test.exe"是不变的吧
int flag = -1;
int nCount = 0;
while(-1 != (flag = strText.ReverseFind(_T('\\'))))
{
if(2 == nCount++)
break;
strText = strText.Left(flag);
}
AfxMessageBox(strText);
CString szExe = "Debug\\test.exe";
CString szResult = str.Left ( str.GetLength() - szExe.GetLength());
LPTSTR p = StrStrI(str,_T("Debug\\Test.exe"));
if (p) *p = 0x00;
_tprintf(_T("%s"),str);