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. Type Conversion ?

Type Conversion ?

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

    Hi, This snippet in my program... USES_CONVERSION; LPCTSTR lpSource = _T("123456"); char szSource[10]; strncpy(szSource,W2A(lpSource),MAX_PATH); TRACE("%c",szSource[0]); When I do unicode build TRACE throws error C2664: 'AfxTrace' : cannot convert parameter 1 from 'char [3]' to 'const unsigned short *' Help me to solve this... :rolleyes:

    R M 2 Replies Last reply
    0
    • M Manikandan

      Hi, This snippet in my program... USES_CONVERSION; LPCTSTR lpSource = _T("123456"); char szSource[10]; strncpy(szSource,W2A(lpSource),MAX_PATH); TRACE("%c",szSource[0]); When I do unicode build TRACE throws error C2664: 'AfxTrace' : cannot convert parameter 1 from 'char [3]' to 'const unsigned short *' Help me to solve this... :rolleyes:

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      Your application is UNICODE, you passed an ANSI string to the TRACE call. Do: TRACE(L"%c", ...); or TRACE(_T("%c"), ...); Roger Allen - Sonork 100.10016 Strong Sad: Clever I am? Next to no one. Undiscovered and soggy. Look up. Look down. They're around. Probably laughing. Still, bright, watery. Listed among the top. Ten. Nine. Late night. Early morn. Early mourn. Now I sleep.

      M 1 Reply Last reply
      0
      • R Roger Allen

        Your application is UNICODE, you passed an ANSI string to the TRACE call. Do: TRACE(L"%c", ...); or TRACE(_T("%c"), ...); Roger Allen - Sonork 100.10016 Strong Sad: Clever I am? Next to no one. Undiscovered and soggy. Look up. Look down. They're around. Probably laughing. Still, bright, watery. Listed among the top. Ten. Nine. Late night. Early morn. Early mourn. Now I sleep.

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

        Yep... it works... In the following... char str[][7] = {"123456", "789012", }; lstrlen(str[0]); under unicode build throws error C2664: 'lstrlenW' : cannot convert parameter 1 from 'char [7]' to 'const unsigned short *' How to handle this? :rolleyes:

        M 1 Reply Last reply
        0
        • M Manikandan

          Yep... it works... In the following... char str[][7] = {"123456", "789012", }; lstrlen(str[0]); under unicode build throws error C2664: 'lstrlenW' : cannot convert parameter 1 from 'char [7]' to 'const unsigned short *' How to handle this? :rolleyes:

          M Offline
          M Offline
          Manikandan
          wrote on last edited by
          #4

          Yep... I found it...its char str[][7] = {"123456", "789012", }; USES_CONVERSION; int val = lstrlen(A2W(str[0])); :)

          1 Reply Last reply
          0
          • M Manikandan

            Hi, This snippet in my program... USES_CONVERSION; LPCTSTR lpSource = _T("123456"); char szSource[10]; strncpy(szSource,W2A(lpSource),MAX_PATH); TRACE("%c",szSource[0]); When I do unicode build TRACE throws error C2664: 'AfxTrace' : cannot convert parameter 1 from 'char [3]' to 'const unsigned short *' Help me to solve this... :rolleyes:

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            Manikandan wrote: char szSource[10]; strncpy(szSource,W2A(lpSource),MAX_PATH); You've got a buffer overrun bug waiting to happen there. You have a 10-char array but you're telling strncpy that you have MAX_PATH chars available, which is 260. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."   -- Paul Watson, Linux Zombie

            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