【问题标题】:How can convert System::Int32 to wchar_t*如何将 System::Int32 转换为 wchar_t*
【发布时间】:2011-08-27 03:20:15
【问题描述】:

我有这段代码:

int casted_dbValue=3;
wchar_t* nativeData=(wchar_t*)casted_dbValue;

int 到 const wchar_t* 之间的转换不正确。如何处理这个错误?

【问题讨论】:

  • @Cody Gray:如果不可能,我可以在System::Int32wchar_t 之间进行转换!怎么样!
  • 您为什么要尝试获取整数值并将其转换为指针?你想在这里做什么?不知道这一点是不可能给出好的答案的。

标签: .net visual-c++ c++-cli wchar-t int32


【解决方案1】:

你试过_itow function吗?

wchar_t * _itow(
                int value,
                wchar_t *str,
                int radix
                );

或者,更安全的版本,_itow_s

第一个参数(value)是要转换的整数值,第二个是字符串结果,第三个是数值的基数。它返回一个指向str 值的指针。

【讨论】:

  • 这个代码`wchar_t* nativeData=_itow(casted_dbValue,wchar_t *nativeData1, 10);`我得到了错误Error 2 error C2062: type 'wchar_t' unexpected
  • @user:指针不是这样工作的……你的函数调用不正确。如果您对指针没有比这更好的理解,那么您将很难编写 C++ 代码。我建议选择good book on C++
  • 我一般都知道如何使用指针..!有什么问题,如果你给我,它会比书本更好,谢谢
猜你喜欢
  • 2013-03-19
  • 2018-01-07
  • 2011-03-14
  • 2021-01-29
  • 2010-09-09
  • 2017-12-12
  • 2011-12-11
相关资源
最近更新 更多