c++ - Trouble with strcpy function -
i have user defined class, 1 of members char*
type. when try initialize in constructor error saying error c4996: 'strcpy': function or variable may unsafe. consider using strcpy_s instead.
however, when changed strcpy strcpy_s, still give following error intellisense: no instance of overloaded function "strcpy_s" matches argument list argument types are: (char *, char *)
let's student
class , char* name;
1 of data members.so, constructor like:
student (char* s = null) { if (s != null) { name = new char[strlen(s) + 1]; //strcpy(name,s); strcpy_s(name,s); } }
it's because strcpy_s requires additional parameter specify how many bytes copy.
Comments
Post a Comment