无法从"const wchar_t *"转换为"_TCHAR *" [英] Cannot convert from 'const wchar_t *' to '_TCHAR *'

查看:1405
本文介绍了无法从"const wchar_t *"转换为"_TCHAR *"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

_TCHAR* strGroupName = NULL;
const _TCHAR* strTempName = NULL;

//Assign some value to strTempName

strGroupName = _tcschr(strTempName, 92) //C2440

在VS2008中编译此代码时,在上一行出现错误.在VC6中,它可以正常编译.

I get an error at the above line while compiling this code in VS2008. In VC6 it compiles fine.

错误C2440:"=":无法从 从'const wchar_t *'到'_TCHAR *'

Error C2440: '=' : cannot convert from 'const wchar_t *' to '_TCHAR *'

似乎是问题所在,我该如何解决?

What seems to be the problem and how do I fix it?

推荐答案

尝试将其强制转换为

strGroupName = (_TCHAR*)_tcschr(strTempName, 92);

在我看来,VS2008在类型转换方面更加严格,并且在某些情况下不会自动执行.

Seems to me that VS2008 got a little more strict on type casts, and won't automatically do them in some cases.

这篇关于无法从"const wchar_t *"转换为"_TCHAR *"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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