草庐IT

strcpy_s

全部标签

c++ - 如何摆脱 Visual Studio 中的 "unsafe"警告/错误(strcpy、sprintf、strdup)

我正在尝试消除一些编译器警告,这些警告说strcpy、sprintf等是不安全的。我明白为什么它们不安全,但我想不出一种修复代码的好方法,以C++风格。这是代码的摘录:extList->names[i]=(char*)malloc(length*sizeof(char));strcpy(extList->names[i],extName);//unsafe//strncpy(extList->names[i],extName,length);//alsounsafe这是消息:C4996:'strcpy':Thisfunctionorvariablemaybeunsafe.Conside

c++ - 错误 : strcpy was not declared in this scope

我在Ubuntug++版本4.4.3中编译的c++问题中遇到了这个问题。我不知道要包含哪些标题来解决这个问题。谢谢centro_medico.cpp:Inconstructor‘Centro_medico::Centro_medico(char*,char*,int,int,float)’:centro_medico.cpp:5:error:‘strcpy’wasnotdeclaredinthisscopecentro_medico.cpp:13:warning:deprecatedconversionfromstringconstantto‘char*’centro_medico.c