Windows strcpy overflow question
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 8 of 8

Thread: Windows strcpy overflow question

Threaded View

  1. #1
    Join Date
    Mar 2009

    Windows strcpy overflow question


    I have the following code:

    char buf[5];
    strcpy(buf, "12345678");

    When I run this from the IDE in Release mode, it works fine, no crashes. However, when I change "12345678" to "123456789" then I get this compilation warning:

    warning C4789: destination of memory copy is too small

    And also it crashes when i run it.

    Can anyone explain why this is inconsistent, or what I am misunderstand?

    Last edited by ekhule; January 15th, 2013 at 10:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)