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. BYTE* to char* or BYTE* to CString ?

BYTE* to char* or BYTE* to CString ?

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • N Offline
    N Offline
    ninck
    wrote on last edited by
    #1

    Can I cast BYTE* to char* , or BYTE* to CString and then back to BYTE ? What should I use for that ?

    J C N 3 Replies Last reply
    0
    • N ninck

      Can I cast BYTE* to char* , or BYTE* to CString and then back to BYTE ? What should I use for that ?

      J Offline
      J Offline
      Jorgen Sigvardsson
      wrote on last edited by
      #2

      Lookup the CP author Mike Dunn. Then look at his String-articles (which he coauthored with Nishant). It should answer any questions you may have on strings. :) -- An eye for an eye will only make the world blind.

      1 Reply Last reply
      0
      • N ninck

        Can I cast BYTE* to char* , or BYTE* to CString and then back to BYTE ? What should I use for that ?

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        BYTE == unsigned char. You can cast it. You cannot cast BYTE* to CString, it's plainly not an instance of the CString class. CString s((char*)myBYTE*); should work tho. Christian Graus - Microsoft MVP - C++

        1 Reply Last reply
        0
        • N ninck

          Can I cast BYTE* to char* , or BYTE* to CString and then back to BYTE ? What should I use for that ?

          N Offline
          N Offline
          neliocc
          wrote on last edited by
          #4

          You cannot cast a BYTE* to char* or CString, but you can convert it to char* whit this method: char* CAST(BYTE* bytes,int numberOfBytes) { char *result=new char[numberOfBytes]; for(int i=0;i

          B 1 Reply Last reply
          0
          • N neliocc

            You cannot cast a BYTE* to char* or CString, but you can convert it to char* whit this method: char* CAST(BYTE* bytes,int numberOfBytes) { char *result=new char[numberOfBytes]; for(int i=0;i

            B Offline
            B Offline
            Bob Stanneveld
            wrote on last edited by
            #5

            A BYTE is the same size as a char, hence you can cast a BYTE pointer to a char pointer. You can even do the following: DWORD d[4] = {0}; char* p = (char* d ); The code isn't going to be more nice with such casts, but you can still get away with it.. Blog[^]

            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