albert
albert

Reputation: 507

wcstombs_s(), length of converted string

errno_t wcstombs_s(
   size_t *pReturnValue,
   char *mbstr,
   size_t sizeInBytes,
   const wchar_t *wcstr,
   size_t count
);

Microsoft VS2019's documentation says:

pReturnValue
The size in bytes of the converted string, including the null terminator.

...

If wcstombs_s successfully converts the source string, it puts the size in bytes of the converted string, including the null terminator, into *pReturnValue (provided pReturnValue is not NULL).

cppreference.com's documentation says:

retval - pointer to a size_t object where the result will be stored

...

Returns zero on success (in which case the number of bytes excluding terminating zero that were, or would be written to dst, is stored in *retval)

Who is wrong ?

Upvotes: 2

Views: 388

Answers (1)

Alex
Alex

Reputation: 1924

Neither. The cppreference is referring to the standards compliant version of the function. The Microsoft documentation is referring to the version implemented in their standard library.

If you're using MS Visual C++, use the Microsoft docs. Otherwise, use the cppreference docs.

Upvotes: 2

Related Questions