strcpy() error in Visual studio 2012

后端 未结 7 1024
Happy的楠姐
Happy的楠姐 2021-02-06 12:50

so I have this code:

#include \"stdafx.h\"
#include 
#include 
#include 
using namespace std;

...<

7条回答
  •  自闭症患者
    2021-02-06 13:23

    There's an explanation and solution for this on MSDN:

    The function strcpy is considered unsafe due to the fact that there is no bounds checking and can lead to buffer overflow.

    Consequently, as it suggests in the error description, you can use strcpy_s instead of strcpy:

    strcpy_s( char *strDestination, size_t numberOfElements,
    const char *strSource );

    and:

    To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

    http://social.msdn.microsoft.com/Forums/da-DK/vcgeneral/thread/c7489eef-b391-4faa-bf77-b824e9e8f7d2

提交回复
热议问题