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. Real quick question...

Real quick question...

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
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.
  • C Offline
    C Offline
    CherezZaboro
    wrote on last edited by
    #1

    I know it's stupid :-O but I'm new to UNICODE ... So. In my code I want to call inet_addr which takes const char* as parameter, but my string which I want to pass is wchar_t. How do I squeeze it into that func? :confused: This is what I get from compiler: error C2664: 'inet_addr' : cannot convert parameter 1 from 'const wchar_t *' to 'const char *' Will it even be able to work with UNICODE string??? MSDN doesn't say a word about UNICODE for this func. I do have _UNICODE in my project defined and everything. Thanks a lot.

    _ L 2 Replies Last reply
    0
    • C CherezZaboro

      I know it's stupid :-O but I'm new to UNICODE ... So. In my code I want to call inet_addr which takes const char* as parameter, but my string which I want to pass is wchar_t. How do I squeeze it into that func? :confused: This is what I get from compiler: error C2664: 'inet_addr' : cannot convert parameter 1 from 'const wchar_t *' to 'const char *' Will it even be able to work with UNICODE string??? MSDN doesn't say a word about UNICODE for this func. I do have _UNICODE in my project defined and everything. Thanks a lot.

      _ Offline
      _ Offline
      _Theo_
      wrote on last edited by
      #2

      You can convert the wchar_t * to char * with one of the following functions: - wcstombs (include stdlib.h) - WideCharToMultiByte (include winnls.h)

      1 Reply Last reply
      0
      • C CherezZaboro

        I know it's stupid :-O but I'm new to UNICODE ... So. In my code I want to call inet_addr which takes const char* as parameter, but my string which I want to pass is wchar_t. How do I squeeze it into that func? :confused: This is what I get from compiler: error C2664: 'inet_addr' : cannot convert parameter 1 from 'const wchar_t *' to 'const char *' Will it even be able to work with UNICODE string??? MSDN doesn't say a word about UNICODE for this func. I do have _UNICODE in my project defined and everything. Thanks a lot.

        L Offline
        L Offline
        Lakitu
        wrote on last edited by
        #3

        Use the WideCharToMultiByte() API. It's documented in MSDN. Set the cbMultiByte parameter to 0 to determine the length of the target (ASCII) buffer. Then allocate a char buffer and call the API again to do the actual conversion. If a train station is where the train stops, what's a workstation...?

        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