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. convert CString to const char *

convert CString to const char *

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

    code to convert CString to const char * using UNICODE in application. so first I need to convert it to ANSI. anyone having working code.

    Future Lies in Present. Manmohan Bishnoi

    D T _ K 4 Replies Last reply
    0
    • M Manmohan29

      code to convert CString to const char * using UNICODE in application. so first I need to convert it to ANSI. anyone having working code.

      Future Lies in Present. Manmohan Bishnoi

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      See here and here.

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      1 Reply Last reply
      0
      • M Manmohan29

        code to convert CString to const char * using UNICODE in application. so first I need to convert it to ANSI. anyone having working code.

        Future Lies in Present. Manmohan Bishnoi

        T Offline
        T Offline
        transoft
        wrote on last edited by
        #3

        Use macro "CT2A()" or "CW2A()"

        1 Reply Last reply
        0
        • M Manmohan29

          code to convert CString to const char * using UNICODE in application. so first I need to convert it to ANSI. anyone having working code.

          Future Lies in Present. Manmohan Bishnoi

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          Use WideCharToMultiByte[^].

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          1 Reply Last reply
          0
          • M Manmohan29

            code to convert CString to const char * using UNICODE in application. so first I need to convert it to ANSI. anyone having working code.

            Future Lies in Present. Manmohan Bishnoi

            K Offline
            K Offline
            Kushagra Tiwari
            wrote on last edited by
            #5

            Firstly if you are using wide char (Unicode)then CString will be of Type CStringW by default and thus all us need to do is if u have : CString str; // do the following CW2A(str); // this will give u const char* else if its Multibyte charset project CString will be of type CStringA by default: // u can directly cast it to char* as below: CString str; //do the following (CHAR*)str.GetString();// this will give u Const char* If you like this ans mark it and close the thread Regards Kushagra

            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