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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:37:09+00:00 2026-05-31T22:37:09+00:00

I am currently making a small C++ tool , and I am kind of

  • 0

I am currently making a small C++ tool , and I am kind of shocked on the way of How to deal with strings in C++. This is the first time i need to deal with C++ , I have pretty much experience with Managed languages with strong types like Java , C# but I am getting mad with C++ strings.

Are there any best practices to work with strings in C++ ?

A lot of WIN API functions dealing with different type of “strings”

tchar , char* , LPWSTR , LPCSTR … etc.
and converting each type to other is taking a lot of time for me to implement.

Please suggest your way of dealing with strings when converting one type to another.
Maybe there is some library to use ?

  • 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-31T22:37:10+00:00Added an answer on May 31, 2026 at 10:37 pm

    Short answer? Use std::string or std::wstring wherever you can is my advice.

    std::string strBuffer = "test";
    strBuffer += " ... test";
    std::string::size_type nStringSize = strBuffer.size();
    const char* pszString = strBuffer.c_str();    // pszString contains 
                                                  // pointer to memory held 
                                                  // by STL string and can be 
                                                  // passed into API calls
    

    You can easily obtain a “c style” string (i.e. a pointer to a null terminate char array char* by .c_str() which you can pass into most WinAPI functions as is.

    Most of the other types you mention (tchar, LPWSTR, LPCSTR etc) are typedefs to C style arrays (or pointers to C style arrays, or char types) for supporting unicode over multibyte character sets.

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

Sidebar

Related Questions

I am currently working directly with Cocoa for the first time to built a
I'm currently making a small program to teach me some new Java, and I'm
I'm currently learning Windows/DOS assembly. I'm just making a small program that adds two
We have a small 3 developer team that is currently using Subversion for our
I am currently making a small test program for simple file checking. The program
Im currently working on a small project in which I need to model the
This is kind of a followup on my previous question . I have an
I'm trying to use WebSockets for the first time, and I'm making a todo
this is my first post so if you need clarificatrion on anything then just
I am learning objective c and am making some small programs. For my current

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.