如何解决(缓冲区太小".0")问题? [英] How to solve (Buffer too Small".0) problem?

查看:1277
本文介绍了如何解决(缓冲区太小".0")问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CString WriteString;
....

	WriteString.Format("%s.%d d",WriteString,NI);



WriteString上方,任何时候执行时都会显示缓冲区太小警告,因为CString type不足以容纳任何大小的字符串.

我的目标是获取WriteString的内容以最后写入文件.

但是当WriteString的大小达到限制时,它会显示警告.还有其他方法可以将这些字符串写入文件吗?或使writeString大小不受限制.



At above WriteStringthe buffer too small warning is shown when executed any times because CStringtype is not enough to hold string of any size.

My goal is to get content ofWriteStringto write in to a file at end.

But it shows the warning when size of WriteStringreach to a limit. Is there any other way to write these strings to a file?or make the writeString be of unlimited size.

推荐答案

WriteString.AppendFormat("%du.",NI,CPianoCtrl::NoteUporDwn);





This also works.


在Format(..)上下文中,
尝试仅将字符串用作接收方:):
In the Format(..) context,
try to use the string as the receiver only :) :
CString cszComposed(_T("SomeValue"));
...
CString cszTemp;
cszTemp.Format(_T(".%d d"), NI);
cszComposed += cszTemp;


如果您的目标是重用变量,则可以使用以下方法:

If your objective is to reuse variables, here goes the way to go:

CString WriteString;
....
 
	WriteString.Format("%s.%d d", CString(WriteString),NI);



注意CString()构造函数调用.您不会有任何问题,因为您的格式会收到WriteString的副本,而不是直接操作它.



Notice the CString() constructor call. You will have not problems because your format receives a copy of WriteString, instead of manipulating it directly.


这篇关于如何解决(缓冲区太小".0")问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆