如何在文件中从末尾查找字符串,返回第一次找到的位置???在线!!!!!!!!!! 同上 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看看strrchr函数的用法,可参见CString::ReverseFind()函数 比如:在C:\\temp\\test.txt找到test.txtint pos;pos=m_sApp.ReverseFind('\\');CString path=m_sApp.Left(pos);CString title=m_sApp.Right(strlen(m_sApp)-pos);tltle就是test.txt了 这是一个记事本查找字符串的片断BOOL PopFindFindText (HWND hwndEdit, int * piSearchOffset, LPFINDREPLACE pfr){ int iLength, iPos ; PTSTR pstrDoc, pstrPos ; // 读入编辑的文本 iLength = GetWindowTextLength (hwndEdit) ; if (NULL == (pstrDoc = (PTSTR) malloc ((iLength + 1) * sizeof (TCHAR)))) return FALSE ; GetWindowText (hwndEdit, pstrDoc, iLength + 1) ; // Search the document for the find string pstrPos = _tcsstr (pstrDoc + * piSearchOffset, pfr->lpstrFindWhat) ; free (pstrDoc) ; // Return an error code if the string cannot be found if (pstrPos == NULL) return FALSE ; // Find the position in the document and the new start offset iPos = pstrPos - pstrDoc ; * piSearchOffset = iPos + lstrlen (pfr->lpstrFindWhat) ; // Select the found text SendMessage (hwndEdit, EM_SETSEL, iPos, * piSearchOffset) ; SendMessage (hwndEdit, EM_SCROLLCARET, 0, 0) ; return TRUE ;}分析一下可能有用 想做一个简易蜜罐,自动捕获网络上各种木马病毒,100分求思路。 怎么不认这个CArray? 如何改变tabcontrol标题栏部分的颜色 ? 关于文档/视图的更新问题, 问题比较多. 逐个算分 如何使用静态链接库? 执行if (!pFrame->LoadFrame(IDR_MAINFRAME))后出错。 定时器如何实现? 如何在其他应用程序中挂入自己的菜单,并通过这些菜单项来调用我自己生成的对话框? 如何把整型数组读入文件,然后再以整型读出 问IOCP和线程池搭配使用的问题? openGL显示列表调用的问题,谢谢帮忙!! 关于完成端口投递IO的问题,大牛进来帮忙看看
在C:\\temp\\test.txt找到test.txt
int pos;
pos=m_sApp.ReverseFind('\\');
CString path=m_sApp.Left(pos);
CString title=m_sApp.Right(strlen(m_sApp)-pos);
tltle就是test.txt了
BOOL PopFindFindText (HWND hwndEdit, int * piSearchOffset, LPFINDREPLACE pfr)
{
int iLength, iPos ;
PTSTR pstrDoc, pstrPos ;
// 读入编辑的文本
iLength = GetWindowTextLength (hwndEdit) ;
if (NULL == (pstrDoc = (PTSTR) malloc ((iLength + 1) * sizeof (TCHAR))))
return FALSE ;
GetWindowText (hwndEdit, pstrDoc, iLength + 1) ;
// Search the document for the find string
pstrPos = _tcsstr (pstrDoc + * piSearchOffset, pfr->lpstrFindWhat) ;
free (pstrDoc) ;
// Return an error code if the string cannot be found
if (pstrPos == NULL)
return FALSE ;
// Find the position in the document and the new start offset
iPos = pstrPos - pstrDoc ;
* piSearchOffset = iPos + lstrlen (pfr->lpstrFindWhat) ;
// Select the found text
SendMessage (hwndEdit, EM_SETSEL, iPos, * piSearchOffset) ;
SendMessage (hwndEdit, EM_SCROLLCARET, 0, 0) ;
return TRUE ;
}
分析一下可能有用