VS2010 MFC CString初始化 [英] VS2010 MFC CString Initialisation

查看:442
本文介绍了VS2010 MFC CString初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的VS2010 MFC应用程序(最近从VS6转换)中,我有一段对话框代码,我正在尝试将CS​​tring初始化为空白。



我有:



In my VS2010 MFC app (which was fairly recently convert from VS6) I have a piece of dialog code where I'm trying to initialize a CString to blank.

I've got:

CString strX = _T("");
strX.Empty();





但是在两次操作之后,调试器显示 strX 变量包含字符串standard。



这让我很生气!



任何人都可以建议它的来源以及如何让我的VS2010 CString 像我的旧VS6一样工作 CString



But after both operations, the debugger shows that the strX variable contains the string "standard".

It's driving me mad!

Can anyone suggest where it is coming from and how to get my VS2010 CString to work like my old VS6 CString?

推荐答案

确定 - 到目前为止,似乎某些第三方代码正在覆盖默认ATL字符串管理器的CNilStringData成员,从而更改了NULL字符串的定义。 。
OK - so far it appears that some third party code is overwriting the CNilStringData member of the default ATL string manager, changing the defition of a NULL string...


找出字符串standard的位置。使用,并检查是否使用了sscanf()函数。如果是这样,也许这就是问题所在。 CString是MFC的一种类型,但是sscanf()是C的一种方法。不要将CString与sscanf()一起使用,只需用char *替换CString即可。希望它对你有帮助。
Find out where the string "standard" is used,and check whether the sscanf() function is used. If so, maybe that is the problem. CString is a type for MFC, however sscanf() is a method of C.Do not use CString with sscanf(), just replace CString with char *. Hope it helps you.


这篇关于VS2010 MFC CString初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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