{Edit}
When you want to use the function template, you must match all parameter types. So you must pass the length of the string instead of a second copy of the c_str() result to the wcsncat_s template:
wcsncat_s(recordsText, ss2.str().c_str(), ss2.str().length());
This will resolve to the prototype
template <size_t size>
errno_t _mbsncat_s(
unsigned char (&strDest)[size],
const unsigned char *strSource,
size_t count
); // C++ only
{/Edit}
Without the template the following applies:
You can't pass an array to a function. The function will only accept the pointer. The array can be well accessed with the pointer inside the function. But you lose the information about the array size.
Since the pointer only points to the first element of the array you can't use
sizeof(*somePointer);
because this gives you the size of the first array element.
You need to change the parameter list of refreshTextField. Since the label
argument points to an output variable you need the size of the variable as an additional parameter. e.g.:
BOOL refreshTextField(CButton* item, wchar_t* label, size_t lableSize, long long* number)
{
std::wstringstream ss;
ss << number;
wcsncat_s(label, labelSize, ss.str().c_str(), ss.str().length());
//...
}