Skip to content

Commit 5d4cf4e

Browse files
authored
Update return value behavior for valid buffer
behave is different than written here.
1 parent e1f66f4 commit 5d4cf4e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

docs/c-runtime-library/reference/vsprintf-p-vsprintf-p-l-vswprintf-p-vswprintf-p-l.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The locale to use.
6868

6969
**`_vsprintf_p`** and **`_vswprintf_p`** return the number of characters written, not including the terminating null character, or a negative value if an output error occurs.
7070
If the *`buffer`* is a `NULL` pointer and *`sizeInBytes`* or *`count`* are zero, functions return the number of characters that would have been written not including the terminating NULL.
71+
If the *`buffer`* is valid and *`sizeInBytes`* or *`count`* are zero, functions return -1.
7172

7273
## Remarks
7374

@@ -79,8 +80,6 @@ The versions of these functions with the `_l` suffix are identical except that t
7980

8081
If the *`buffer`* or *`format`* parameters are `NULL` pointers, or if the format string contains invalid formatting characters, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, the functions return -1 and set `errno` to `EINVAL`.
8182

82-
If the *`buffer`* is valid and *`sizeInBytes`* or *`count`* parameters are zero, behavior is unpredictable.
83-
8483
> [!IMPORTANT]
8584
> Starting in Windows 10 version 2004 (build 19041), the `printf` family of functions prints exactly representable floating point numbers according to the IEEE 754 rules for rounding. In previous versions of Windows, exactly representable floating point numbers ending in '5' would always round up. IEEE 754 states that they must round to the closest even digit (also known as "Banker's Rounding"). For example, both `printf("%1.0f", 1.5)` and `printf("%1.0f", 2.5)` should round to 2. Previously, 1.5 would round to 2 and 2.5 would round to 3. This change only affects exactly representable numbers. For example, 2.35 (which, when represented in memory, is closer to 2.35000000000000008) continues to round up to 2.4. Rounding done by these functions now also respects the floating point rounding mode set by [`fesetround`](fegetround-fesetround2.md). Previously, rounding always chose `FE_TONEAREST` behavior. This change only affects programs built using Visual Studio 2019 version 16.2 and later. To use the legacy floating point rounding behavior, link with ['legacy_stdio_float_rounding.obj`](../link-options.md).
8685

0 commit comments

Comments
 (0)