比如我用CStdioFile类打开一个文件,按行读取
CStdioFile file;
if (!(file.Open(filename, CFile::modeRead))) {
AfxMessageBox(_T("文件打开失败")); return false;
}
CString strT;
while (file.ReadString(strT)) {
if (strT.Find("正确")!= -1)
return true;
};
无论文件里有没有“正确”结果都是未找到
文件的编码和MFC的编码是一样的吗,如果不一样要转换一下
if (strT.Find(_T("正确"))!= -1)
CString s( "abcdef" );
ASSERT( s.Find( 'c' ) == 2 );
ASSERT( s.Find( "de" ) == 3 );
// Second example demonstrating
// CString::Find( TCHAR ch, int nStart )
CString str("The stars are aligned");
int n = str.Find('e', 5);
ASSERT(n == 12);