In message <c2ch4h$sq2$1$8300dec7@news.demon.co.uk>, Julius Mong
<jxm96c@hotmail.com> writes[color=blue]
>Hi all, I'm doing this:[/color]
I assume you are using C++ because of the other newsgroup you cross
posted to, but other internals suggest that you may actually be
compiling as C.
[color=blue]
>
> // Test char code
> wchar_t lookup[] = {0x8364, 0x5543, 0x3432, 0xabcd, 0xef01};[/color]
OK, very odd magic numbers but they should work OK but the compiler will
convert them to whatever wchar_t expects (and the type of wchar_t is
different between C and C++. In the former it is just a typedef for some
suitable integer type -- possibly unsigned short. In C++ it is a type of
its own.[color=blue]
> for (int x=0; x<5; x++) {
> wchar_t * string = (wchar_t*) malloc(sizeof(wchar_t));[/color]
so the very unwisely named variable (string) is a pointer to some memory
for storing an array of wchar_t but why?[color=blue]
> string = (wchar_t*)lookup[1];[/color]
Now you take that pointer to malloced memory and try to forceably make
it use the value found in lookup[1] (which is a wchar_t value) as a
pointer to wchar_t. You are really confused. Please describe in words
exactly what you are trying to do and in which language. Even if you got
your code to work it sure would not be doing anything that you expect.[color=blue]
> string[sizeof(wchar_t)] = '\0';
> CComBSTR bstrTest = SysAllocString(string);
> }
>
>And the line string=lookup[...] gives me this error:
>
> error C2440: '=' : cannot convert from 'unsigned short' to 'unsigned
>short *'
>
>Can someone tell me what I'm missing? I've tried casting it to (wchar_t*)
>and it'd crash as expected... I'm stuck...
>
>Thanks, Jules
>
>
>
>[/color]
--
Francis Glassborow ACCU
Author of 'You Can Do It!' see
http://www.spellen.org/youcandoit
For project ideas and contributions:
http://www.spellen.org/youcandoit/projects