小编Ali*_*din的帖子

为什么将strncpy标记为不安全?

我收到警告:

warning C4996: 'strncpy': This function or variable may be unsafe. Consider using  strncpy_s instead.
To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
F:\vuStudio\VC\include\string.h(188) : see declaration of 'strncpy'
Run Code Online (Sandbox Code Playgroud)

我在stackoverflow.com上阅读这strcpy并不安全,应该strncpy改用。但是现在为什么我要警告strncpy不安全?

我称它为:

strncpy(this->title, title.c_str(), sizeof(this->title));
Run Code Online (Sandbox Code Playgroud)

c++

4
推荐指数
2
解决办法
1789
查看次数

标签 统计

c++ ×1