当前位置:网站首页>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 lock Optimization Practice issued by gaobingfa
- Visual host system design and development (Halcon WinForm)
- Detailed explanation of string function and string function with unlimited length
- 使用JMeter对WebService进行压力测试
- Using multipleoutputs to output multiple files in MapReduce
- Custom annotation
- Nppexec get process return code
- 视觉上位系统设计开发(halcon-winform)-3.图像控件
- 整形和浮点型是如何在内存中的存储
- Digital image processing -- popular understanding of corrosion and expansion
猜你喜欢

What is machine reading comprehension? What are the applications? Finally someone made it clear
![Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)](/img/cd/2e4f5884d034ff704809f476bda288.png)
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)

WinDbg分析dump文件

C language brush questions ~leetcode and simple questions of niuke.com

Kubernetes vous emmène du début à la fin

String functions that you need to know

Creation and destruction of function stack frames

百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式

【可能是全中文网最全】pushgateway入门笔记

Basic SQL tutorial
随机推荐
高并发下之redis锁优化实战
Popular understanding of linear regression (I)
运维体系的构建
How are integer and floating-point types stored in memory
Halcon与Winform学习第二节
Backtracking method to solve batch job scheduling problem
【可能是全中文网最全】pushgateway入门笔记
整形和浮点型是如何在内存中的存储
Digital image processing -- popular understanding of corrosion and expansion
Markdown file titles are all reduced by one level
Enable multi-threaded download of chrome and edge browsers
Digital image processing -- popular Canny edge detection
WinDbg分析dump文件
[daily training] 395 Longest substring with at least k repeated characters
Stress test WebService with JMeter
SQL server installation location cannot be changed
Construction of operation and maintenance system
Jvm-06-execution engine
MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)
CString中使用百分号