TCHAR name[MAX_PATH]={'\0'};
lstrcat(name,"F:\Rec.txt");
CString sm,pm;
CStdioFile read(name,CFile::modeRead);
while(read.ReadString(pm))
{
if( pm.Find(sub_temp)== -1)
{
read.ReadString(pm);
}
sm+=pm;
sm+="\r\n";
}
SetDlgItemText(IDC_EDIT1,sm);
为什么查找的结果不现实第一次找到的那一行,求赐教。
是有问题的,请使用这个:
你可以用CString的ReverseFind方法来查找,代码如下:
比如:
CString str = "@111#222@333";
int index = str.ReverseFind('@');
CString::ReverseFind
int ReverseFind( TCHAR ch ) const;
返回值:
返回此CString对象中与要求的字符匹配的最后一个字符的索引;如果没有找到需要的字符则返回-1。
参数: ch 要搜索的字符。
说明:
此成员函数在此CString对象中搜索与一个子串匹配的最后一个字符。此函数类似于运行时函数strrchr。