I am getting this weird error with _snprintf_s:
int ival = strlen("F(LL)L");
char buff[32];
memset(buff,0,sizeof(buff));
_snprintf_s(buff,strlen("F(LL)L"),_TRUNCATE,"%s","F(LL)L");
In buff only "F(LL)" is copied even though the string length is computed as 6.
in case I specify the length parameter as strlen("F(LL)L") + 1 complete string is copied.
The second argument to _snprintf_s() is the size of the target buffer (in bytes). One byte has to be reserved for the terminating
NULcharacter, that’s why the last character of your input string is not copied.It would be better (and much safer) to pass the actual size of the buffer instead of the length of the input string: