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. const char error

const char error

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++visual-studio
10 Posts 4 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi I am getting a number of errors in MFC functions (Using Visual Studio 2012) can't convert const char [xx] to LPCTSTR when using a literal with " double qoute it was my understanding that anything with " was a pointer now weather its char * or LPCTSTR is a different issue however it shouldn't be of type const char[xx] Thanks

    L D V 3 Replies Last reply
    0
    • F ForNow

      Hi I am getting a number of errors in MFC functions (Using Visual Studio 2012) can't convert const char [xx] to LPCTSTR when using a literal with " double qoute it was my understanding that anything with " was a pointer now weather its char * or LPCTSTR is a different issue however it shouldn't be of type const char[xx] Thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Do you have the project set to use the Unicode character set? If so LPC**T**STR is equivalent to LPC**W**STR, so you cannot convert a char pointer to it.

      F 1 Reply Last reply
      0
      • L Lost User

        Do you have the project set to use the Unicode character set? If so LPC**T**STR is equivalent to LPC**W**STR, so you cannot convert a char pointer to it.

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        Richard you did it again !!!!! ;)

        L 1 Reply Last reply
        0
        • F ForNow

          Hi I am getting a number of errors in MFC functions (Using Visual Studio 2012) can't convert const char [xx] to LPCTSTR when using a literal with " double qoute it was my understanding that anything with " was a pointer now weather its char * or LPCTSTR is a different issue however it shouldn't be of type const char[xx] Thanks

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

          Try using TCHAR instead of char, and wrapping string literals in the _T() macro.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "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

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          1 Reply Last reply
          0
          • F ForNow

            Richard you did it again !!!!! ;)

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Thanks. Sadly my flashes of brilliant intuition are getting fewer and further apart these days. :(

            1 Reply Last reply
            0
            • F ForNow

              Hi I am getting a number of errors in MFC functions (Using Visual Studio 2012) can't convert const char [xx] to LPCTSTR when using a literal with " double qoute it was my understanding that anything with " was a pointer now weather its char * or LPCTSTR is a different issue however it shouldn't be of type const char[xx] Thanks

              V Offline
              V Offline
              vishwadeepak mani tripathi
              wrote on last edited by
              #6

              Please read __What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR (etc.)?[^]

              F 2 Replies Last reply
              0
              • V vishwadeepak mani tripathi

                Please read __What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR (etc.)?[^]

                F Offline
                F Offline
                ForNow
                wrote on last edited by
                #7

                I prefixed the string with a _T macro And it compiled Thanks for your help I have to re-read and he article

                1 Reply Last reply
                0
                • V vishwadeepak mani tripathi

                  Please read __What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR (etc.)?[^]

                  F Offline
                  F Offline
                  ForNow
                  wrote on last edited by
                  #8

                  In my visual Studio project for character set I choose not sure what that means ansi? 1 byte The other two choices were Unicode and multi byte So if Unicode is character representation by 2 bytes. what is multi byte ?

                  D 1 Reply Last reply
                  0
                  • F ForNow

                    In my visual Studio project for character set I choose not sure what that means ansi? 1 byte The other two choices were Unicode and multi byte So if Unicode is character representation by 2 bytes. what is multi byte ?

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

                    ForNow wrote:

                    So if Unicode is character representation by 2 bytes. what is multi byte ?

                    See here.

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "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

                    "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                    F 1 Reply Last reply
                    0
                    • D David Crow

                      ForNow wrote:

                      So if Unicode is character representation by 2 bytes. what is multi byte ?

                      See here.

                      "One man's wage rise is another man's price increase." - Harold Wilson

                      "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

                      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                      F Offline
                      F Offline
                      ForNow
                      wrote on last edited by
                      #10

                      So if I select for my project setting char set -> not set .... And wrap all of my strings with a _T( macro is that best practice ... Thanks

                      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