读书人

使用C++标准库怎么实现CString:GetBuf

发布时间: 2012-03-17 19:06:28 作者: rapoo

使用C++标准库如何实现CString::GetBuffer()的功能

有这样一个函数,GetModuleFileName( HANDLE hModule, char * psz, int nSize )获取本程序的全路径。

CString strPath;
GetModuleFileName( NULL, strPath.GetBuffer( MAX_PATH ), MAX_PATH );
strPath.ReleaseBuffer();

此时strPath就存储的就是本程序的全路径了。

请问在标准库中有没有哪个类返回非const char*的函数。我试过将string()::c_str()返回的const char *中的const去掉,结果还是不对。stringstream也试过,好像也没有返回char *的函数。

不要使用字符串数组

[解决办法]
string 木有
用vector<char> 吧
[解决办法]

探讨

引用:

引用:
引用:

引用:
string 木有
用vector<char> 吧

vector<char> 是可以,我想知道stringstream可以不?或者还有没有更好的选择?

stringstream不行。。

看来这还真是标准库的一……

读书人网 >C++

热点推荐