Solved

_mbscat, mbscpy error

Posted on 2002-05-07
4
600 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
  • 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 300 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
cb: unreferenced local variable 11 66
TTimer no longer functioning 7 74
how to understand recursion 12 206
Getting IP address 8 67
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now