Home > Software engineering >  'wcscpy' : this function or variable may not be safe
'wcscpy' : this function or variable may not be safe

Time:12-18

 

TCHAR * GetCurrentPath (TCHAR * path)
{
TCHAR filename [_MAX_PATH]={0};
GetModuleFileName (NULL, filename, _MAX_PATH);
_tcsrchr (filename, '\' \ ') [1]=0;
_tcscpy (the path and filename);//write after the program did not suggest there is an error, but click compile time, the line error, an error the following
Return path.
}

C4996 'wcscpy' : This function or variable may be unsafe. Consider using wcscpy_s home. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See the online help for details. The Custom: L, the Custom, the Custom, PCH. CPP 13


Translation: 'wcscpy' : this function or variable may not be safe, can consider to use wcscpy_s, to disable deprecation, can use _CRT_SECURE_NO_WARNINGS, for details please refer to the online help,

CodePudding user response:

Using the new wcscpy_s

CodePudding user response:

With function of _s _tcscpy_s

CodePudding user response:

This is for a class does not specify the size of the buffer function of warning and prevent you took not to be trusted (foreign) long, carefully build the data to write DST, overflow caused by holes
MSDN recommend replacing it with StringCchCopy.
  • Related