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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:19:58+00:00 2026-06-05T10:19:58+00:00

I am attempting to copy a LPTSTR and store that string as a member

  • 0

I am attempting to copy a LPTSTR and store that string as a member variable in an object. But my attempts to copy the LPTSTR seem to fail and when I go to access/print the value of the copied LPTSTR I get a program crash.

Is it possible to copy a LPTSTR and store it in my class below or is it better to just use a TCHAR*?

class Checkbox
{
   private:
      LPTSTR text;
      HWND hwnd;

   public:
      Checkbox(HWND nHwnd, LPTSTR nText)
      {
        lstrcpy(checkText, text); 
      }

      void print()
      {
        // Causes a crash
        MessageBox(hwnd, text, text, MB_OK);
      }
};
  • 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-05T10:20:00+00:00Added an answer on June 5, 2026 at 10:20 am

    LPTSTR is just a pointer. So, you need to take care to allocate memory before using it. So is the case with TCHAR*. Alternatively you could use wstring, if you have to worry about unicode strings.

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

Sidebar

Related Questions

I am attempting to re-implement the Copy behavior for a QTextEdit object. The custom
currently I'm attempting to basically implement and exact copy of Apples iMessage App. That
Attempting to copy/paste a 159KB TSQL query into Microsoft Access 2010 passthrough query editor
I'm attempting to copy the database located, as an example, in: /data/data/com.x.x.x/databases/mydb.db This works
Attempting to make a NSObject called 'Person' that will hold the login details for
I'm attempting to copy cells, one at a time, from an Excel 2003 (or
I am trying to copy some property values from one object to another (both
I'm attempting to remove Component elements from the XML below that have File children
I am attempting to write some code that will expediently process video frames. I
When attempting to create a tag of a working copy we receive the error,

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.