当前位置:网站首页>CString getbuffer and releasebuffer instructions
CString getbuffer and releasebuffer instructions
2022-07-03 15:26:00 【Yulong_】
Let's start with a piece of code :
#include <atlstr.h>
// test CString
int main(int argc, _TCHAR* argv[])
{
CStringA strTemp = "555";
// The output here is 3, No terminator
printf("str=%s,len=%d\n",strTemp.GetBuffer(),strTemp.GetLength());
LPSTR lpStr = strTemp.GetBuffer(10);
// The output here is 3, Because of GetBuffer The return value of , Not invoked ReleaseBuffer,GetLength() The returned result will be incorrect
strcpy(lpStr,"666666");
printf("str=%s,len=%d\n",strTemp.GetBuffer(),strTemp.GetLength());
strTemp.ReleaseBuffer();
// Because the call ReleaseBuffer,GetLength() The returned result is 6
printf("str=%s,len=%d\n",strTemp.GetBuffer(),strTemp.GetLength());
system("pause");
return 0;
}
Running results :
ReleaseBuffer Source code :
void ReleaseBuffer(_In_ int nNewLength = -1)
{
边栏推荐
- Redis cache penetration, cache breakdown, cache avalanche solution
- 【可能是全中文网最全】pushgateway入门笔记
- Backtracking method to solve batch job scheduling problem
- 子类隐藏父类的同名函数
- 视觉上位系统设计开发(halcon-winform)-1.流程节点设计
- 开启 Chrome 和 Edge 浏览器多线程下载
- 秒殺系統3-商品列錶和商品詳情
- Summary of JVM knowledge points
- SQL server installation location cannot be changed
- XWiki安装使用技巧
猜你喜欢
Kubernetes will show you from beginning to end
Seckill system 3- product list and product details
Creation and destruction of function stack frames
秒杀系统3-商品列表和商品详情
"Seven weapons" in the "treasure chest" of machine learning: Zhou Zhihua leads the publication of the new book "machine learning theory guide"
Jvm-02-class loading subsystem
视觉上位系统设计开发(halcon-winform)-3.图像控件
C language brush questions ~leetcode and simple questions of niuke.com
redis缓存穿透,缓存击穿,缓存雪崩解决方案
The markdown file obtains the pictures of the network and stores them locally and modifies the URL
随机推荐
GCC cannot find the library file after specifying the link library path
Introduction to redis master-slave, sentinel and cluster mode
秒杀系统3-商品列表和商品详情
Detailed comments on MapReduce instance code on the official website
运维体系的构建
What is label encoding? How to distinguish and use one hot encoding and label encoding?
视觉上位系统设计开发(halcon-winform)
Redis主从、哨兵、集群模式介绍
Popular understanding of ovo and ovr
Kubernetes帶你從頭到尾捋一遍
[transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team
Summary of JVM knowledge points
Tensorflow realizes verification code recognition (III)
The difference between RAR and zip files
How to use annotations such as @notnull to verify and handle global exceptions
视觉上位系统设计开发(halcon-winform)-4.通信管理
找映射关系
Construction of operation and maintenance system
Visual upper system design and development (Halcon WinForm) -4 Communication management
开启 Chrome 和 Edge 浏览器多线程下载