Advertisement

07.30.2008 at 02:07PM PDT, ID: 23609049
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

Convert wchar_t* to char* function, memory cleanup problem

Asked by LearningCpp in Windows MFC Programming

Tags:

Hi,
in my application, at lot of places i need to convert a cstring or wchar_t* to char*, hence i wrote a function in a cpp file, not belonging to any class such as:
char* ConvertWCHARtoCHAR(const wchar_t* wcharString, int intMaxChar)
{
      char *charMultibyte;
      charMultibyte = new char[intMaxChar];
      if(!(wcstombs(charMultibyte,wcharString,sizeof(charMultibyte)) == -1))
            return charMultibyte;
      else
            return NULL;
}

I am sure the charMultibyte is not cleaned up since i am using new but no delete.
I am not using a class here hence i cannot use destructor to clean the memory, any way to solve this problem.

P.S: the reason i wrote this function cause, say if one of the function Foo requires input as char* and i have a wchar_t* with me, i can call directly:
Foo(ConvertWCHARtoCHAR(my_w_char_string));

I have to use Foo a lot of times and everywhere i have cstrings, my application is compiled in Unicode

Start Free Trial
[+][-]07.30.2008 at 02:16PM PDT, ID: 22124870

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 02:42PM PDT, ID: 22125075

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 03:02PM PDT, ID: 22125186

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 03:05PM PDT, ID: 22125208

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 03:32PM PDT, ID: 22125378

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 03:58PM PDT, ID: 22125523

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 07:03PM PDT, ID: 22126405

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 07:16PM PDT, ID: 22126487

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 07:24PM PDT, ID: 22126512

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 08:24PM PDT, ID: 22126699

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 08:39PM PDT, ID: 22126756

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Windows MFC Programming
Tags: c++
Sign Up Now!
Solution Provided By: jkr
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.31.2008 at 10:57AM PDT, ID: 22131954

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.31.2008 at 12:32PM PDT, ID: 22132789

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.31.2008 at 01:08PM PDT, ID: 22133063

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 - Hierarchy / EE_QW_2_20070628