当前位置:网站首页>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)
{
边栏推荐
- What is one hot encoding? In pytoch, there are two ways to turn label into one hot coding
- Halcon and WinForm study section 2
- Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
- "Seven weapons" in the "treasure chest" of machine learning: Zhou Zhihua leads the publication of the new book "machine learning theory guide"
- Popular understanding of decision tree ID3
- Tensorflow realizes verification code recognition (I)
- [transformer] Introduction - the original author of Harvard NLP presented the annotated transformer in the form of line by line implementation in early 2018
- 高并发下之redis锁优化实战
- 运维体系的构建
- Jvm-02-class loading subsystem
猜你喜欢
基础SQL教程
运维体系的构建
【云原生训练营】模块七 Kubernetes 控制平面组件:调度器与控制器
Functional modules and application scenarios covered by the productization of user portraits
Visual upper system design and development (Halcon WinForm) -5 camera
Summary of JVM knowledge points
Solve the problem that pushgateway data will be overwritten by multiple push
What are the composite types of Blackhorse Clickhouse, an OLAP database recognized in the industry
Kubernetes vous emmène du début à la fin
北京共有产权房出租新规实施的租赁案例
随机推荐
MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)
Using Tengine to solve the session problem of load balancing
Besides lying flat, what else can a 27 year old do in life?
Popular understanding of ovo and ovr
win32创建窗口及按钮(轻量级)
Kubernetes advanced training camp pod Foundation
Popular understanding of gradient descent
Jvm-03-runtime data area PC, stack, local method stack
Detailed comments on MapReduce instance code on the official website
Halcon与Winform学习第二节
Popular understanding of linear regression (II)
[transformer] Introduction - the original author of Harvard NLP presented the annotated transformer in the form of line by line implementation in early 2018
Introduction to redis master-slave, sentinel and cluster mode
【云原生训练营】模块八 Kubernetes 生命周期管理和服务发现
Redis lock Optimization Practice issued by gaobingfa
Redis single thread problem forced sorting layman literacy
视觉上位系统设计开发(halcon-winform)-6.节点与宫格
redis单线程问题强制梳理门外汉扫盲
Puppet automatic operation and maintenance troubleshooting cases
基于SVN分支开发模式流程浅析