字符串使用总结

来源:互联网 发布:淘宝助理上传宝贝教程 编辑:程序博客网 时间:2024/05/21 06:45

1.如何获取EXE路径

CString GetExePath(){ char szExePath[MAX_PATH]={0}; char* pszSlash; DWORD dwRet = GetModuleFileName( NULL, szExePath, MAX_PATH ); //assert( dwRet != 0 ); pszSlash = strrchr( szExePath, '\\' ); if ( NULL != pszSlash )  pszSlash[1] = 0; return CString(szExePath);}


(1)strrchr         

函数功能:查找一个字符c在另一个字符串str中末次出现的位置(也就是从str的右侧开始查找字符c首次出现的位置),并返回从字符串中的这个位置起,一直到字符串结束的所有字符。如果未能找到指定字符,那么函数将返回NULL。

 2.CString::GetBuffer()

参考http://blog.csdn.net/just_kong/article/details/12152609

原创粉丝点击