Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6230277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:43:03+00:00 2026-05-24T09:43:03+00:00

Not much of a C++ developer and the multiple ways to handle strings always

  • 0

Not much of a C++ developer and the multiple ways to handle strings always confuses me.

int Mine_SSL_Read(SSL* ssl, void* buf, int size)
{
    int length = Real_SSL_Read(ssl, buf, size);

    CString msg = ???
}

However I need to write a hook for SSL_Read function (OpenSSL) and that requires some C++ code. I need to convert buf which is of type void* and has a length of “length” into a CString so it can be parsed by other code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:43:04+00:00Added an answer on May 24, 2026 at 9:43 am

    Assuming the void* is simply one-byte (ASCII or similar) characters:

    If you know it is NULL terminated, you can simply cast it:

    // ASCII
    CString msg = reinterpret_cast<char*>(buf);
    
    // UNICODE
    CString msg = reinterpret_cast<wchar_t*>(buf);
    

    If it is not NULL terminated, or you don’t know that fact, then you have to copy it byte by byte (I don’t believe CString has an assign function similar to std::string).

    CString msg;
    
    char* str_buf = msg.GetBuffer();
    char* msg_buf = reinterpret_cast<char*>(buf);
    
    for(int x = 0; x < size; ++x)
        *str_buf++ = *msg_buf++;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a developer ... not so much the UI guru type. I can get
This is something I'm not much consistent about and always curious about what other
I've been working as a software developer for almost a year (not much though)
Background: I'm an ASP.NET developer with not much of experience when it comes to
I have not seen much support for Grails to develop facebook apps.I was just
not much of a programming question, but development related still, I'm starting Android development
Not much to say about this question...
Probably not much more to elaborate on here - I'm using a NumericStepper control
I'm not much of a Visual Basic person, but I am tasked with maintaining
I'm not much into COM interfaces, so i have a small question, say I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.