当前位置:网站首页>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)
{
边栏推荐
- Summary of JVM knowledge points
- 官网MapReduce实例代码详细批注
- Idea does not specify an output path for the module
- win32创建窗口及按钮(轻量级)
- 详解指针进阶2
- Jvm-08-garbage collector
- Concurrency-01-create thread, sleep, yield, wait, join, interrupt, thread state, synchronized, park, reentrantlock
- Custom annotation
- Visual upper system design and development (Halcon WinForm) -4 Communication management
- What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
猜你喜欢
Jvm-02-class loading subsystem
秒杀系统1-登录功能
Visual upper system design and development (Halcon WinForm) -4 Communication management
[transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team
秒杀系统2-Redis解决分布式Session问题
百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式
详解指针进阶1
求字符串函数和长度不受限制的字符串函数的详解
Creation and destruction of function stack frames
【云原生训练营】模块七 Kubernetes 控制平面组件:调度器与控制器
随机推荐
秒杀系统1-登录功能
Tensorflow realizes verification code recognition (II)
如何使用 @NotNull等注解校验 并全局异常处理
Halcon and WinForm study section 1
Summary of JVM knowledge points
Concurrency-01-create thread, sleep, yield, wait, join, interrupt, thread state, synchronized, park, reentrantlock
[attention mechanism] [first vit] Detr, end to end object detection with transformers the main components of the network are CNN and transformer
秒殺系統3-商品列錶和商品詳情
The difference between RAR and zip files
[combinatorics] permutation and combination (set permutation, step-by-step processing example)
自定义注解
Seckill system 3- product list and product details
Kubernetes带你从头到尾捋一遍
Detailed comments on MapReduce instance code on the official website
Visual upper system design and development (Halcon WinForm) -1 Process node design
QT use qzxing to generate QR code
[cloud native training camp] module 7 kubernetes control plane component: scheduler and controller
Analysis of development mode process based on SVN branch
Redis主从、哨兵、集群模式介绍
[transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team