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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:23:47+00:00 2026-06-08T20:23:47+00:00

Alright so I have an edit control and a static text control. When the

  • 0

Alright so I have an edit control and a static text control. When the user clicks a button, I want the program to take the text from the edit control and add it to the text in the static text control and then set that new value as the text in the static control. So I have a function that appends the buffers to one another but my program doesn’t seem to be working. This is what I have:

//when button message is recieved:
SendMessage(hwndEditControl, WM_GETTEXT,255,(LPARAM)editbuffer);
GetWindowText(hwndTextControl, (LPWSTR)allText, GetWindowTextLength(hwndTextControl));
allText = appendStrings((char*)editbuffer, (char*)allText);
SetWindowText(hwndTextControl, (LPCWSTR)allText);}

 // where appendStrings is defined as:

char* appendStrings (char* buffer1, char* buffer2)
{
    std::string string1(buffer1), string2(buffer2);
    std::string string3 = string1 + string2; 
    return (char*)string3.c_str();
}
//and
static char*        editbuffer = new char;
static char*        allText    = new char; //these are defined as so

So anyway, when I push the button, I’m pretty sure that the appendStrings function is working because I think it takes what is in the editbox and adds it to the Text box. The reason I say “i think” though is because the string in the text box is always just jibberish. Its sometimes random symbols or just these “l’s” (or what look like “L”s). I think it’s a problem with my pointers but I’m not sure. I’m new to this so if there is an easier way, please tell me.

  • 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-08T20:23:48+00:00Added an answer on June 8, 2026 at 8:23 pm

    You’re returning a pointer to a temporary that’s being destroyed before the function returns.

    Instead of returning a char *, return a std::string.

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

Sidebar

Related Questions

Alright, I have this program to sparse code in Newick Format, which extracts both
In my program I have a memory DC to which I frequenty draw, then
Alright, so I'm trying to implement text-shadow across various browsers. I have IE6, IE7,
EDIT: So, I want to take a different approach to try and clarify what
I have a user control that's got an image ..when I added it to
i have a problem with wxpython and his rich text control, when I try
Alright so here it goes, I have my user system working perfectly, and now
Alright have been working to switch to jQuery 1.7's new and improved .on() function
Alright i have a for loop in php and it generates a group of
Alright so I have no idea how to even begin doing this But basically

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.