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. unsigned char, char, CString

unsigned char, char, CString

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
3 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi! I have to encrypt a string of text. My text is a CString. The function I call is this:

    encrypt(const unsigned char* in, unsigned char* out, size_t n)

    I have this:

    CString strOutput, strInput = "hello world";
    int len = strInput.GetLength();
    unsigned char *buf = new unsigned char[len];
    memset(buf, 0, len);
    strcpy(buf, strInput); // !!!! This does not compile
    encrypt(buf, buf, len);
    strOutput = buf;
    delete [] buf;

    Can anyone tell me how to convert from a CString to a unsigned char *?

    B M 2 Replies Last reply
    0
    • A Anonymous

      Hi! I have to encrypt a string of text. My text is a CString. The function I call is this:

      encrypt(const unsigned char* in, unsigned char* out, size_t n)

      I have this:

      CString strOutput, strInput = "hello world";
      int len = strInput.GetLength();
      unsigned char *buf = new unsigned char[len];
      memset(buf, 0, len);
      strcpy(buf, strInput); // !!!! This does not compile
      encrypt(buf, buf, len);
      strOutput = buf;
      delete [] buf;

      Can anyone tell me how to convert from a CString to a unsigned char *?

      B Offline
      B Offline
      BlackDice
      wrote on last edited by
      #2

      try this: sprintf(buf,"%s",strInput); If it's broken, I probably did it bdiamond

      1 Reply Last reply
      0
      • A Anonymous

        Hi! I have to encrypt a string of text. My text is a CString. The function I call is this:

        encrypt(const unsigned char* in, unsigned char* out, size_t n)

        I have this:

        CString strOutput, strInput = "hello world";
        int len = strInput.GetLength();
        unsigned char *buf = new unsigned char[len];
        memset(buf, 0, len);
        strcpy(buf, strInput); // !!!! This does not compile
        encrypt(buf, buf, len);
        strOutput = buf;
        delete [] buf;

        Can anyone tell me how to convert from a CString to a unsigned char *?

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

        Hello! or try this: strcpy(buf, (LPCTSTR)strInput); :)

        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