I was wondering what is the correct way?
_tcscpy(tchar_pointer, _tcslen(tchar_pointer), _T("Hello World"));
or
_tcscpy(tchar_pointer, _tcsclen(tchar_pointer), _T("Hello World"));
_tcscpy(tchar_pointer, ???, _T("Hello World"));
the tchar pointer comes from the outside and my side doesn't know how big the buffer pointed by the pointer is
If so, then none of them will do what you want.
How all the "safe" functions work, you indicate how large the target buffer is.
You do not know? You cannot use these features.
int buffer_size = _tcslen(xxx) * sizeof(TCHAR)
. , , , . , ; '\0', ; ..
'\0'
, _tcscpy_s, _tcscpy, , . :
_tcscpy_s
_tcscpy
TCHAR dest[20]; _tcscpy_s(dest, _countof(dest), _T("Hello"));
, :
_tcscpy_s(dest, _T("Hello"));
tchar_pointer , ( ), . , , .
tchar_pointer
, . _tcslen _tcsclen, .
Unicode _tcslen _tcsclen TCHAR . TCHAR wchar_t.
_tcslen TCHAR . TCHAR char. _tcsclen . - TCHAR, - . , .
tchar_pointer - ( ), , . , , strcpy_s .
strcpy_s