当前位置:网站首页>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)
{
边栏推荐
- 视觉上位系统设计开发(halcon-winform)-6.节点与宫格
- What is machine reading comprehension? What are the applications? Finally someone made it clear
- redis单线程问题强制梳理门外汉扫盲
- 自定义注解
- Tensorflow realizes verification code recognition (III)
- socket.io搭建分布式Web推送服务器
- Detailed pointer advanced 1
- 详解指针进阶2
- [combinatorics] combinatorial identities (recursive combinatorial identities | sum of variable terms | simple combinatorial identities and | sum of variable terms | staggered sums of combinatorial ide
- Summary of concurrent full knowledge points
猜你喜欢

Halcon and WinForm study section 1

Introduction, use and principle of synchronized

Basic SQL tutorial

Tensorflow realizes verification code recognition (III)

Popular understanding of linear regression (II)

从 flask 服务端代码自动生成客户端代码 -- flask-native-stubs 库介绍

北京共有产权房出租新规实施的租赁案例
![MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)](/img/cd/2e4f5884d034ff704809f476bda288.png)
MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)

Popular understanding of decision tree ID3

详解指针进阶1
随机推荐
Redis cache penetration, cache breakdown, cache avalanche solution
视觉上位系统设计开发(halcon-winform)-2.全局变量设计
The markdown file obtains the pictures of the network and stores them locally and modifies the URL
Concurrency-02-visibility, atomicity, orderliness, volatile, CAS, atomic class, unsafe
Halcon and WinForm study section 2
qt使用QZxing生成二维码
阿特拉斯atlas扭矩枪 USB通讯教程基于MTCOM
VC下Unicode和ANSI互转,CStringW和std::string互转
[combinatorics] permutation and combination (set permutation, step-by-step processing example)
软件逆向破解入门系列(1)—xdbg32/64的常见配置及功能窗口
Enable multi-threaded download of chrome and edge browsers
The method of parameter estimation of user-defined function in MATLAB
[probably the most complete in Chinese] pushgateway entry notes
Popular understanding of random forest
XWiki Installation Tips
求字符串函数和长度不受限制的字符串函数的详解
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)
Markdown file titles are all reduced by one level
Matplotlib drawing label cannot display Chinese problems
Summary of JVM knowledge points