问题描述
CString WriteString;
....
WriteString.Format("%s.%d d",WriteString,NI);
在WriteString
上方,任何时候执行时都会显示缓冲区太小警告,因为CString
type不足以容纳任何大小的字符串.
我的目标是获取WriteString
的内容以最后写入文件.
但是当WriteString
的大小达到限制时,它会显示警告.还有其他方法可以将这些字符串写入文件吗?或使writeString大小不受限制.
At above WriteString
the buffer too small warning is shown when executed any times because CString
type is not enough to hold string of any size.
My goal is to get content ofWriteString
to write in to a file at end.
But it shows the warning when size of WriteString
reach 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.
CString cszComposed(_T("SomeValue"));
...
CString cszTemp;
cszTemp.Format(_T(".%d d"), NI);
cszComposed += cszTemp;
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")问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!