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

Thread: Windows strcpy overflow question

Threaded View

  1. #1
    Join Date
    Mar 2009
    Posts
    166

    Windows strcpy overflow question

    Hello,

    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?

    Regards,
    EK
    Last edited by ekhule; January 15th, 2013 at 09: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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center