GetBuffer解析
来源:互联网 发布:软件测试各个阶段 编辑:程序博客网 时间:2024/06/01 08:10
CString str=_T("abc");LPTSTR lpstr=str.GetBuffer(10);lstrcpy(lpstr,_T("01234"));TRACE(str);//输出01234
如果你对GetBuffer返回的指针内容修改了,那么在你在使用CString的方法之前你必须调用ReleaseBuffer
CString str=_T("abc");//长度3LPTSTR lpstr=str.GetBuffer(10);lstrcpy(lpstr,_T("01234"));str.ReleaseBuffer();//str+="hello";int iLen=str.GetLength();CString strLen;strLen.Format(_T("%d"),iLen);TRACE(str);TRACE(_T("\n"));TRACE(strLen);
输出结果:
str:01234
长度:3-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CString str=_T("abc");LPTSTR lpstr=str.GetBuffer(10);lstrcpy(lpstr,_T("01234"));str.ReleaseBuffer();//str+="hello";int iLen=str.GetLength();CString strLen;strLen.Format(_T("%d"),iLen);TRACE(str);TRACE(_T("\n"));TRACE(strLen);
输出结果:str:01234
长度:5——————————————————————————————————————————————————————————————
CString str=_T("abc");LPTSTR lpstr=str.GetBuffer(10);lstrcpy(lpstr,_T("01234"));//str.ReleaseBuffer();str+="hello";int iLen=str.GetLength();CString strLen;strLen.Format(_T("%d"),iLen);TRACE(str);TRACE(_T("\n"));TRACE(strLen);
输出结果:str:012hello
长度:8-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CString str=_T("abc");LPTSTR lpstr=str.GetBuffer(10);lstrcpy(lpstr,_T("01234"));str.ReleaseBuffer();str+="hello";int iLen=str.GetLength();CString strLen;strLen.Format(_T("%d"),iLen);TRACE(str);TRACE(_T("\n"));TRACE(strLen);
输出结果:str:01234hello
长度:10-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
我只是测试了这其中一项,有什么不对的地方,欢迎指正!
- GetBuffer解析
- GetBuffer
- GetBuffer()
- CString GetBuffer用法,GetBuffer本质,GetBuffer常见问题
- CString GetBuffer()
- GetBuffer(0)
- GetBuffer(0)
- GetBuffer ReleaseBuffer
- GetBuffer(0)
- GetBuffer()、LPCTSTR
- GetBuffer 认识
- GetBuffer()
- CString的GetBuffer用法,GetBuffer本质,GetBuffer常见问题解决方法
- CString的GetBuffer用法,GetBuffer本质,GetBuffer常见问题解决方法
- CString的GetBuffer用法,GetBuffer本质,GetBuffer常见问题解决方法
- CString的GetBuffer用法,GetBuffer本质,GetBuffer常见问题解决方法
- CString的GetBuffer用法,GetBuffer本质,GetBuffer常见问题解决方法
- CString的GetBuffer用法,GetBuffer本质,GetBuffer常见问题解决方法
- ERP远程管理解决方案
- PHP文件包含include(),require(),require_once()
- 根据IP自动切换城市(腾讯网接口)
- BZOJ 3505: [Cqoi2014]数三角形 题解
- PHP的false与0
- GetBuffer解析
- 如何查看Tomcat是否安装配置成功
- 349. Intersection of Two Arrays不重复的记录两个数组中共同的数字
- PHP foreach循环
- java发送邮箱
- Shell脚本函数定义和函数参数
- 把二元查找树转变成排序的双向链表
- Struts2的数据验证框架validation framework
- IPC机制之AIDL实现客户端回调