?
Solved

_mbscat, mbscpy error

Posted on 2002-05-07
4
Medium Priority
?
624 Views
Last Modified: 2007-12-19
Hello all,
I have written a function that used _mbscat and _mbscpy to change string to hexa string but it gets error. Please help me to solve this problem. Here is my function:

int StringToHexString(unsigned char * Source)
{
     char buffer[MAX_LEN_PASSWORD];
     unsigned char password[MAX_LEN_PASSWORD];
     int i;    
     password[0] = '\0';
     int len = strlen((char *)Source);
     for (i = 0; i < len; i++)
     {
          _ultoa(Source[i], buffer, 16);
          if (strlen((char *)buffer) < 2)
               _mbscat(password, (const unsigned char *)"0");

          _mbscat(password, (const unsigned char *)buffer);
     }
     _mbscpy(Source, password);
     return 1;
}

Do not try to help me to write another function. Just help me to make it better. Error just appears on Win2k.
Thanks.
0
Comment
Question by:GloriousRain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 6994126
Error?? What error?
0
 
LVL 32

Expert Comment

by:jhance
ID: 6994129
What about this question:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=20177990

Are you ever going to resolve it?

Why should an expert waste time on this question if you're likely to just leave it hanging as well?
0
 
LVL 86

Accepted Solution

by:
jkr earned 1200 total points
ID: 6994177
Use '_mbslen()' instead of 'strlen()' - don't mix up the ANSI, UNICODE and MBCS functions.
0
 
LVL 2

Author Comment

by:GloriousRain
ID: 6994341
Thank you so much, jkr. That works fine now.
jhance, thanks for your comments. Please forgive me, i have not much time.
Thank you all.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question