How to solve (Buffer too Small".0) problem?

来源:互联网 发布:mac windows10截图 编辑:程序博客网 时间:2024/05/24 01:10
CString WriteString;.... WriteString.Format("%s.%d d",WriteString,NI);


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 of WriteString 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.


Solution 1:

In the Format(..) context,
try to use the string as the receiver only Smile | :) :

CString cszComposed(_T("SomeValue"));  ...  CString cszTemp;  cszTemp.Format(_T(".%d d"), NI);  cszComposed += cszTemp;


Solution 2:

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

This also works.


原创粉丝点击