C++ 'strcpy' gives a Warning (C4996)

前端 未结 9 1144
孤城傲影
孤城傲影 2020-12-03 08:15

I am getting this warning but all functions working properly .

what does this really means?

\'strcpy\': This function or variable may be unsafe. 
Con         


        
9条回答
  •  孤城傲影
    2020-12-03 08:24

    Since VC++ 8 strcpy() and a huge set of other functions are considered to be unsafe since they don't have bounds checking and can lead to a buffer overrun if misused.

    You have two options:

    • if you're unsure - do what VC++ says and use "safe" functions. They will trigger an error handler that will terminate your program if something goes wrong.
    • if you know what you're doing - you know that no overrun will ever occur and all edge cases are handled by your code - define _CRT_SECURE_NO_WARNINGS prior to including CRT headers and this will make the warning go away.

提交回复
热议问题