You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Write formatted data to a string. More secure versions of some of these functions are available; see [`sprintf_s`, `_sprintf_s_l`, `swprintf_s`, `_swprintf_s_l`](sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md). The secure versions of **`swprintf`** and **`_swprintf_l`** take the size of the buffer as a parameter.
15
15
@@ -21,37 +21,49 @@ int sprintf(
21
21
const char *format [,
22
22
argument] ...
23
23
);
24
+
24
25
int_sprintf_l(
25
26
char *buffer,
26
27
const char *format,
27
28
_locale_t locale [,
28
29
argument] ...
29
30
);
31
+
30
32
intswprintf(
31
33
wchar_t *buffer,
32
34
size_t count,
33
35
const wchar_t *format [,
34
36
argument]...
35
37
);
38
+
39
+
int_swprintf(
40
+
wchar_t *buffer,
41
+
const wchar_t *format [,
42
+
argument]...
43
+
);
44
+
36
45
int_swprintf_l(
37
46
wchar_t *buffer,
38
47
size_t count,
39
48
const wchar_t *format,
40
49
_locale_t locale [,
41
50
argument] ...
42
51
);
52
+
43
53
int__swprintf_l(
44
54
wchar_t *buffer,
45
55
const wchar_t *format,
46
56
_locale_t locale [,
47
57
argument] ...
48
58
);
59
+
49
60
template <size_t size>
50
61
intsprintf(
51
62
char (&buffer)[size],
52
63
const char *format [,
53
64
argument] ...
54
65
); // C++ only
66
+
55
67
template <size_t size>
56
68
int_sprintf_l(
57
69
char (&buffer)[size],
@@ -97,7 +109,7 @@ The **`sprintf`** function formats and stores a series of characters and values
97
109
98
110
**`swprintf`** is a wide-character version of **`sprintf`**; the pointer arguments to **`swprintf`** are wide-character strings. Detection of encoding errors in **`swprintf`** may differ from **`sprintf`**. **`swprintf`** and **`fwprintf`** behave identically except **`swprintf`** writes output to a string rather than to a destination of type `FILE`, and **`swprintf`** requires the *`count`* parameter to specify the maximum number of characters to write. The versions of these functions with the **`_l`** suffix are identical except they use the locale parameter passed in instead of the current thread locale.
99
111
100
-
**`swprintf`** conforms to the ISO C Standard, which requires the second parameter, *`count`*, of type **`size_t`**. To force the old nonstandard behavior, define `_CRT_NON_CONFORMING_SWPRINTFS`. In a future version, the old behavior may be removed, so code should be changed to use the new conformant behavior.
112
+
Before the signature for `swprintf` was standardized, a version shipped in an older Microsoft C runtime library that didn't take the character count parameter. The older version is still available in the Microsoft C runtime library, but it's deprecated and was renamed `_swprintf()`. For code that was written against the older signature, define `_CRT_NON_CONFORMING_SWPRINTFS` which maps calls to `swprintf` to `_swprintf`. In a future version, the old behavior may be removed, so code should be changed to use the new conformant behavior.
101
113
102
114
In C++, these functions have template overloads that invoke the newer, secure counterparts of these functions. For more information, see [Secure template overloads](../secure-template-overloads.md).
103
115
@@ -113,7 +125,7 @@ In C++, these functions have template overloads that invoke the newer, secure co
113
125
| Routine | Required header |
114
126
|---|---|
115
127
|**`sprintf`**, **`_sprintf_l`**|`<stdio.h>`|
116
-
|**`swprintf`**, **`_swprintf_l`**|`<stdio.h>` or `<wchar.h>`|
128
+
|**`swprintf`**, **`_swprintf`**, **`_swprintf_l`**|`<stdio.h>` or `<wchar.h>`|
117
129
118
130
For more compatibility information, see [Compatibility](../compatibility.md).
0 commit comments