当前位置:网站首页>CString的GetBuffer和ReleaseBuffer使用说明
CString的GetBuffer和ReleaseBuffer使用说明
2022-07-03 15:20:00 【宇龍_】
先看一段代码:
#include <atlstr.h>
//测试CString
int main(int argc, _TCHAR* argv[])
{
CStringA strTemp = "555";
//这里输出为3,不包含结束符
printf("str=%s,len=%d\n",strTemp.GetBuffer(),strTemp.GetLength());
LPSTR lpStr = strTemp.GetBuffer(10);
//这里输出为3,因为对GetBuffer的返回值进行了操作,未调用ReleaseBuffer,GetLength()返回结果将不正确
strcpy(lpStr,"666666");
printf("str=%s,len=%d\n",strTemp.GetBuffer(),strTemp.GetLength());
strTemp.ReleaseBuffer();
//由于调用了ReleaseBuffer,GetLength()的返回结果就为6
printf("str=%s,len=%d\n",strTemp.GetBuffer(),strTemp.GetLength());
system("pause");
return 0;
}
运行结果:
ReleaseBuffer源码:
void ReleaseBuffer(_In_ int nNewLength = -1)
{
边栏推荐
- 基于SVN分支开发模式流程浅析
- Kubernetes帶你從頭到尾捋一遍
- [transform] [practice] use pytoch's torch nn. Multiheadattention to realize self attention
- Second kill system 3 - list of items and item details
- Baidu AI Cloud helps Shizuishan upgrade the smart health care model of "Internet + elderly care services"
- Introduction to redis master-slave, sentinel and cluster mode
- Calibre LVL
- socket.io搭建分布式Web推送服务器
- 视觉上位系统设计开发(halcon-winform)-6.节点与宫格
- Popular understanding of linear regression (II)
猜你喜欢
[pytorch learning notes] datasets and dataloaders
Besides lying flat, what else can a 27 year old do in life?
Second kill system 3 - list of items and item details
【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer
Jvm-03-runtime data area PC, stack, local method stack
【可能是全中文网最全】pushgateway入门笔记
Kubernetes 进阶训练营 Pod基础
视觉上位系统设计开发(halcon-winform)-1.流程节点设计
百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式
Solve the problem that pushgateway data will be overwritten by multiple push
随机推荐
Global and Chinese markets for indoor HDTV antennas 2022-2028: Research Report on technology, participants, trends, market size and share
运维体系的构建
【pytorch学习笔记】Datasets and Dataloaders
Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
视觉上位系统设计开发(halcon-winform)-5.相机
Qt常用语句备忘
秒杀系统3-商品列表和商品详情
Halcon与Winform学习第一节
视觉上位系统设计开发(halcon-winform)-6.节点与宫格
Matlab r2011b neural network toolbox precautions
Visual upper system design and development (Halcon WinForm) -6 Nodes and grids
Using multipleoutputs to output multiple files in MapReduce
Summary of JVM knowledge points
Redis single thread problem forced sorting layman literacy
【pytorch学习笔记】Transforms
GCC cannot find the library file after specifying the link library path
QT common sentence notes
基于SVN分支开发模式流程浅析
Use of Tex editor
从 flask 服务端代码自动生成客户端代码 -- flask-native-stubs 库介绍