I have structure
NewStruct1
{
uint factor;
NewStruct2 assert[3];
char name[21];
}
and another
NewStruct2
{
uint newFactor;
char newName[21];
}
Here I am calling a function ‘func’ in a dll, as follows
NewStruct1 var;
func(&var);
The function is
func(NewStruct1 *v)
{
std::string myName = "werttt";
strcpy_s(v->assert[0].newName, myName.size(), myName.c_str());
}
While doing so strcpy_s gives (L"Buffer is too small" && 0) even though there is enough space to accommodate. Can any body please help me on this?
The second argument of
strcpy_smust be number of elements in destination, that is, 21 (number of chars in innewName), not the length of the source.