_wmemcpy problem

Posted on 2005-04-13
Last Modified: 2013-11-17
The following code produces unexpected results whereby the buffer is populated correctly by memcpy bur not so buy _memcpy; _wmemcpy appends additional characters after "Hello" I have tried this with BCB 5 and BCB6 with the same results in each case.

Is this a bug ?

#include <mem.h>
#include <string.h>

char buff[40];


Question by:alcindor
    1 Comment
    LVL 3

    Accepted Solution

    It is not a bug.

    _wmemcpy is a wide string version of memcpy, the string you have given is 5 bytes long, but you instruct the function to copy 5 words (10 bytes)

    correct could would be:
     _wmemcpy( buff, L"Hello", 5 );

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
    Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now