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

前端 未结 9 1141
孤城傲影
孤城傲影 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:44

    Since you’re programming C++, the correct solution is to ban C-style char* strings from your code where possible, and replace them by std::string (or another appropriate string type).

    Do not use functions such as strcpy or strcpy_s or strncpy. Use the copy constructor or assignment operator of the string class. Or if you really need to copy buffers, use std::copy.

提交回复
热议问题