一个MFC中的CString的Mid()函数使用问题?

2025-03-01 01:59:50
推荐回答(3个)
回答1:

在file.Read(ab.GetBuffer(dwFileLen),dwFileLen);//文件中有字符abcdefgh
后面加一个ab.ReleaseBuffer();就可以了
这个是CString一个很容易出奇怪错的地方,具体原因我也不清楚

回答2:

CString tmp=(a.Mid(0,3));//tmp应该是abc
变量a是什么?是不是ab

Remarks
Returns a pointer to the internal character buffer for the CString object. The returned LPTSTR is not const and thus allows direct modification of CString contents.
If you use the pointer returned by GetBuffer to change the string contents, you must call ReleaseBuffer before using any other CString member functions. //看看这里

你读取CFile的时候可以建一个字符指针
char* buff;
file.Read(buff,dwFileLen);//文件中有字符abcdefgh
ab=buff;

回答3:

就是截取一段字符串,(起始地址, 截取长度)