Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. cannot convert from 'char *' to 'unsigned short *'

cannot convert from 'char *' to 'unsigned short *'

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    santhoshv84
    wrote on last edited by
    #1

    Hi Friends, I am doing a UNICODE project, Here i am using wchar_t * variable and i am taking name of the file from CString.GetBuffer(). Here i am getting the :confused:error C2440: 'initializing' : cannot convert from 'char *' to 'unsigned short *' Please help me. Its urgent....

    C CPalliniC 2 Replies Last reply
    0
    • S santhoshv84

      Hi Friends, I am doing a UNICODE project, Here i am using wchar_t * variable and i am taking name of the file from CString.GetBuffer(). Here i am getting the :confused:error C2440: 'initializing' : cannot convert from 'char *' to 'unsigned short *' Please help me. Its urgent....

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      First, never ever use GetBuffer without having read the documentation. CString has casting operator so that you don't have to use GetBuffer. You should only use this function if you want access to the internal buffer of the CString. Read the doc carefully if you don't want nasty surprises in your code. You should prefer the use of TCHAR instead of char or wchar. This way, everything is either char or wchar depending on the UNICODE settings and you don't have to worry about conversions. Now, maybe you'll still need a conversion: what are you doing with this wchar string ?

      Cédric Moonen Software developer
      Charting control [v1.2]

      1 Reply Last reply
      0
      • S santhoshv84

        Hi Friends, I am doing a UNICODE project, Here i am using wchar_t * variable and i am taking name of the file from CString.GetBuffer(). Here i am getting the :confused:error C2440: 'initializing' : cannot convert from 'char *' to 'unsigned short *' Please help me. Its urgent....

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        santhoshv84 wrote:

        I am doing a UNICODE project,

        Sure?

        santhoshv84 wrote:

        Here i am getting the error C2440: 'initializing' : cannot convert from 'char *' to 'unsigned short *'

        Probably you aren't doing a UNICODE build. check if the _UNICODE preprocessor symbol is defined for your project. BTW: probably you don't need either to access CString internal buffer, hence avoid to call GetBuffer method. BTW 2: maybe better to use generic text data, i.e. TCHAR insted of w_char. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups