XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

WCHAR problem

Last post 11/30/2008 7:26 PM by getviewsnow. 3 replies.
  • 11/28/2008 2:56 PM

    WCHAR problem

    Hello guys,

    Lets say I have a WCHAR variable which contains a location of 3D Model:
    WCHAR g_Model[MAX_PATH] = L"somemodel.x";

    Now, In application it happens that I want to change the model from somemodel.x to someothermodel.x

    I use the case, where I try to change g_Model variable to handle "someothermodel.x", but I get error:
     error C2440: '=' : cannot convert from 'const wchar_t [14]' to 'WCHAR'

    So, I made new WCHAR called g_Model2 which contains someothermodel.x, and I tried:
    g_Model = g_Model2

    Compiles well, but application crushes (yes, I have tried setting that device does re-set after this change).
    Debugger shows tons of stupid errors.

    BTW: I have tried changing WCHAR to something else, but didnt work out.



  • 11/28/2008 4:04 PM In reply to

    Re: WCHAR problem

    wcscpy(g_Model, L"someothermodel.x"); did the job
  • 11/28/2008 7:16 PM In reply to

    Re: WCHAR problem

    If the size of g_Model is not big enough to hold the new model string, then you have created a memory overrun, which is a potential security problem (and a crash that may happen anytime).

    It seems that you don't quite understand how strings, arrays and pointers work in C/C++. Thus, I suggest you first learn the language you want to use, before you try to do 3D graphics.
    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 11/30/2008 7:26 PM In reply to

    Re: WCHAR problem

    WCHAR max path is 260, which is quite enough (I use like 100 MAX), so no security problems here.
Page 1 of 1 (4 items) Previous Next