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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Initialize into TCHAR**

Initialize into TCHAR**

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
8 Posts 3 Posters 1 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
    m_mun
    wrote on last edited by
    #1

    Hello all, I have a function like below int fn_RecognizeWord(TCHAR** strUnicode) { string unicodeStr; ..... //Problem in this line strcpy(strUnicode[0],unicodeStr.c_str()); } How can i initialize into 'strUnicode' variable using 'unicodeStr' variable. For example 'unicodeStr' variable contains just a single line of string, like '80653478'. Thanks to all

    C N 2 Replies Last reply
    0
    • M m_mun

      Hello all, I have a function like below int fn_RecognizeWord(TCHAR** strUnicode) { string unicodeStr; ..... //Problem in this line strcpy(strUnicode[0],unicodeStr.c_str()); } How can i initialize into 'strUnicode' variable using 'unicodeStr' variable. For example 'unicodeStr' variable contains just a single line of string, like '80653478'. Thanks to all

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

      What is the problem ? Did you initialize your strUnicode array properly ? What I mean is, did you create an array of TCHAR* of the correct size, then for each of these pointers allocate the correct number of characters ? The second step is probably easier to do once you know the size of your string:

      strUnicode[0] = new TCHAR[unicodeStr.size()];
      strcpy(strUnicode[0],unicodeStr.c_str());

      Cédric Moonen Software developer
      Charting control [v2.0] OpenGL game tutorial in C++

      M 1 Reply Last reply
      0
      • C Cedric Moonen

        What is the problem ? Did you initialize your strUnicode array properly ? What I mean is, did you create an array of TCHAR* of the correct size, then for each of these pointers allocate the correct number of characters ? The second step is probably easier to do once you know the size of your string:

        strUnicode[0] = new TCHAR[unicodeStr.size()];
        strcpy(strUnicode[0],unicodeStr.c_str());

        Cédric Moonen Software developer
        Charting control [v2.0] OpenGL game tutorial in C++

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

        It is not working. I testing it with MessageBox(), but this statement not working

        C 1 Reply Last reply
        0
        • M m_mun

          It is not working. I testing it with MessageBox(), but this statement not working

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

          What do you mean it's not working ? Could you explain what you are expecting, what do you get and show some code ?

          Cédric Moonen Software developer
          Charting control [v2.0] OpenGL game tutorial in C++

          M 1 Reply Last reply
          0
          • M m_mun

            Hello all, I have a function like below int fn_RecognizeWord(TCHAR** strUnicode) { string unicodeStr; ..... //Problem in this line strcpy(strUnicode[0],unicodeStr.c_str()); } How can i initialize into 'strUnicode' variable using 'unicodeStr' variable. For example 'unicodeStr' variable contains just a single line of string, like '80653478'. Thanks to all

            N Offline
            N Offline
            Naveen
            wrote on last edited by
            #5

            Shaheen.India wrote:

            strcpy(strUnicode[0],unicodeStr.c_str());

            If the vairable name in your code make sense, I must say that you cannot simply copy the content of a string to a UNICODE pointer. you have to use MultiByteToWideChar() function or mbrtowc() function

            nave [OpenedFileFinder] [My Blog]

            M 1 Reply Last reply
            0
            • C Cedric Moonen

              What do you mean it's not working ? Could you explain what you are expecting, what do you get and show some code ?

              Cédric Moonen Software developer
              Charting control [v2.0] OpenGL game tutorial in C++

              M Offline
              M Offline
              m_mun
              wrote on last edited by
              #6

              Actually it gives "Please tell Microsoft about this problem." window when it executes that line

              1 Reply Last reply
              0
              • N Naveen

                Shaheen.India wrote:

                strcpy(strUnicode[0],unicodeStr.c_str());

                If the vairable name in your code make sense, I must say that you cannot simply copy the content of a string to a UNICODE pointer. you have to use MultiByteToWideChar() function or mbrtowc() function

                nave [OpenedFileFinder] [My Blog]

                M Offline
                M Offline
                m_mun
                wrote on last edited by
                #7

                No its just a string like '973465', store into 'unicodeStr'

                C 1 Reply Last reply
                0
                • M m_mun

                  No its just a string like '973465', store into 'unicodeStr'

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

                  I suggest you read this excellent article[^] to get a better grasp on character encoding.

                  Cédric Moonen Software developer
                  Charting control [v2.0] OpenGL game tutorial in C++

                  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