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 LPCTSTR

Convert CString to LPCTSTR

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
11 Posts 6 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.
  • K karmendra_js

    hi, Can you plz tell me how to Convert CString to LPCTSTR. Thanks a lot.:rose:

    T Offline
    T Offline
    toxcct
    wrote on last edited by
    #2

    this[^] is the only thing I can give now... learn how to search the web and the msdn if your not satisfied X| -- modified at 9:57 Wednesday 12th October, 2005

    D K 2 Replies Last reply
    0
    • K karmendra_js

      hi, Can you plz tell me how to Convert CString to LPCTSTR. Thanks a lot.:rose:

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #3

      have a look below ...


      Maximilien Lincourt Your Head A Splode - Strong Bad

      T 1 Reply Last reply
      0
      • M Maximilien

        have a look below ...


        Maximilien Lincourt Your Head A Splode - Strong Bad

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #4

        thanks !!! :doh: i really can't understand people on the forum... i've been vote down one more time while i gave the answer... :((


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        R 1 Reply Last reply
        0
        • T toxcct

          thanks !!! :doh: i really can't understand people on the forum... i've been vote down one more time while i gave the answer... :((


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          R Offline
          R Offline
          Roger Stoltz
          wrote on last edited by
          #5

          Well, if you are referring to your previous answer in this thread it could be the fact that the code you wrote will generate a compile time error. You're suggesting assigning a 'const char*' to a 'char'.;) On the other hand the answer should give the one asking the question the idea anyway, so I don't think it deserved to be rated '1'. I'll rate it up for you a little bit, if you want. :cool: -- Roger

          T 1 Reply Last reply
          0
          • R Roger Stoltz

            Well, if you are referring to your previous answer in this thread it could be the fact that the code you wrote will generate a compile time error. You're suggesting assigning a 'const char*' to a 'char'.;) On the other hand the answer should give the one asking the question the idea anyway, so I don't think it deserved to be rated '1'. I'll rate it up for you a little bit, if you want. :cool: -- Roger

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #6

            thank you very much, you're too good :D i corrected my wrong code, but i just wanted to show how to use the (LPCTSTR) cast operator...


            TOXCCT >>> GEII power
            [toxcct][VisualCalc]

            I 1 Reply Last reply
            0
            • T toxcct

              this[^] is the only thing I can give now... learn how to search the web and the msdn if your not satisfied X| -- modified at 9:57 Wednesday 12th October, 2005

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

              toxcct wrote: CString str = "Hello World"; char* pc; strcpy(pc, (LPCTSTR)str); While I understand the intent of your code, there are two things wrong with it. First is that no memory has been allocated to pc. Second, the cast in strcpy() is not needed.


              "One must learn from the bite of the fire to leave it alone." - Native American Proverb

              1 Reply Last reply
              0
              • T toxcct

                thank you very much, you're too good :D i corrected my wrong code, but i just wanted to show how to use the (LPCTSTR) cast operator...


                TOXCCT >>> GEII power
                [toxcct][VisualCalc]

                I Offline
                I Offline
                icabod
                wrote on last edited by
                #8

                Not meaning to be picky, but that code won't work either as you're copying to a pointer that doesn't point to anything. But that's not the point. Your original "look at the other threads" comment was valid, which is why I voted it up earlier :]

                T 1 Reply Last reply
                0
                • I icabod

                  Not meaning to be picky, but that code won't work either as you're copying to a pointer that doesn't point to anything. But that's not the point. Your original "look at the other threads" comment was valid, which is why I voted it up earlier :]

                  T Offline
                  T Offline
                  toxcct
                  wrote on last edited by
                  #9

                  icabod wrote: But that's not the point. Your original "look at the other threads" comment was valid, which is why I voted it up earlier :] visibly, not everyone understood that we were talking about the use of the (LPCTSTR) cast operator... I really don't see why i continue awering/helping people that don't take 1 minute of their time to see if their question is not already on the last 50 ones on the forum ... such behaviors sucks... (and i don't care to be voted down for this... :mad: )


                  TOXCCT >>> GEII power
                  [toxcct][VisualCalc]

                  1 Reply Last reply
                  0
                  • T toxcct

                    this[^] is the only thing I can give now... learn how to search the web and the msdn if your not satisfied X| -- modified at 9:57 Wednesday 12th October, 2005

                    K Offline
                    K Offline
                    karmendra_js
                    wrote on last edited by
                    #10

                    I am really sorry Mr. toxcct. Usually i search for article and i search in forum. But this time i didnot find anything in message search (LPCTSTR and LPCSTR string miss match). And its my mistake that i just overlooked the thread below. And i am happy that first reply of those threads posted by Rage helped me. Thanks and Sorry:rose: :)

                    T 1 Reply Last reply
                    0
                    • K karmendra_js

                      I am really sorry Mr. toxcct. Usually i search for article and i search in forum. But this time i didnot find anything in message search (LPCTSTR and LPCSTR string miss match). And its my mistake that i just overlooked the thread below. And i am happy that first reply of those threads posted by Rage helped me. Thanks and Sorry:rose: :)

                      T Offline
                      T Offline
                      toxcct
                      wrote on last edited by
                      #11

                      ok, no problem now... what angry me the most is seeing that i am flamed when i'm trying to help someone...


                      TOXCCT >>> GEII power
                      [toxcct][VisualCalc]

                      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