错误:
VC程序运行时提示下图的错误,但并不是每次都提示。
解决:
The call will fail if the string object itself is offered as a parameter to Format. For example, the following code:
CString str = "Some Data";
str.Format("%d%d", str, 123); //Attention: str is also used in the parameter list.
will cause unpredictable results.
为了避免这种无法预见的问题,最好不要采取将字符串本身作为参数作为Format的参数,可以另外定义一个CString变量:
cstring str,strTmp;
strTmp="asd....";
str.format("%s",strTmp);
这样问题就解决了。
本文详细介绍了在使用VC程序时,将字符串对象本身作为Format参数可能导致的不可预知问题,并提供了避免此类问题的方法,通过定义额外的字符串变量来解决问题。

被折叠的 条评论
为什么被折叠?



