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 7854913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:13:53+00:00 2026-06-02T20:13:53+00:00

If I convert a std::string into a CString using something like: std::string ss(Foo); CString

  • 0

If I convert a std::string into a CString using something like:

std::string ss("Foo");
CString cs( ss.c_str() );

Does the CString copy the characters from ss or does it simply copy the char* pointer?

My understanding of the c_str() function is that it returns a pointer to a character array owned by the std::string. So having a CString using this internally would seem like a really bad idea as any nonconstant method on either of them would then invalidate the pointer held in the other.

  • 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-06-02T20:13:55+00:00Added an answer on June 2, 2026 at 8:13 pm

    The CString constructor that takes a const char* will copy the data into its internal structure. It’s the same as doing this:

    CString test = "This is a test"
    or even this
    CString test("This is a test")

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to convert an ASCII string like... hello2 into it's decimal and or
I have an NSString object and want to convert it into a std::string .
I am trying to do something like this: QString string; // do things... std::cout
I faced a problem cannot convert parameter from 'System::String ^' to 'std::string' . How
I found the code to convert a hexadecimal string into a signed int using
I am trying to convert a standard std::string into an NSString but I'm not
How can I convert a C++ std::string object into a Ruby VALUE object? I
I'm trying to convert std::string to float/double . I tried: std::string num = 0.6;
Possible Duplicate: C++ std::string conversion problem on Windows How to convert std::string to LPCSTR?
What's the easiest way to convert a C++ std::string to another std::string, which has

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.