Solved

_mbscat, mbscpy error

Posted on 2002-05-07
4
612 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.net build a IF/Then Walkthrough Guide 1 211
Template syntax for variable length arrays 9 75
C++ question 3 65
Need some help with Microsoft Visual Studio C++ 2003 5 60
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

773 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