0

I have this piece of code:

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

it is incorrect conversion between int to const wchar_t*. How can deal with this error?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Aan
  • 12,247
  • 36
  • 89
  • 150
  • @Cody Gray: if it is impossible, can i do the conversion between `System::Int32` to `wchar_t` ! how! – Aan May 17 '11 at 10:41
  • Why are you trying to take an integer value and cast it to a pointer? What are you trying to do here? It's not possible to give a good answer without knowing this. – David Thornley May 17 '11 at 15:05

1 Answers1

2

Have you tried the _itow function?

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

Or, the more secure version, _itow_s.

The first parameter (value) is the integer value to be converted, the second is the string result, and the third is the base of the numeric value. It returns a pointer to the str value.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • this the code ` wchar_t* nativeData=_itow( casted_dbValue,wchar_t *nativeData1, 10 );` and i got the error `Error 2 error C2062: type 'wchar_t' unexpected` ! – Aan May 17 '11 at 12:27
  • @user: That's not how pointers work... Your function call is incorrect. You're going to have a very hard time writing C++ code if you don't have any better understanding of pointers than that. I recommend picking up a [good book on C++](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Cody Gray - on strike May 17 '11 at 12:32
  • i know in general how to use pointers.. ! what was the problem, if u give me hent it will be better than the books,, thanks – Aan May 17 '11 at 12:57