Skip to content

Commit 6c9903a

Browse files
Merge pull request MicrosoftDocs#4836 from TylerMSFT/f1
F1
2 parents 01c0454 + 191654c commit 6c9903a

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

docs/c-runtime-library/reference/sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
2-
description: "Learn more about: sprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l"
2+
description: "Learn more about: sprintf, _sprintf_l, swprintf, _swprintf, _swprintf_l, __swprintf_l"
33
title: "sprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l"
44
ms.date: "3/9/2021"
5-
api_name: ["__swprintf_l", "sprintf", "_sprintf_l", "_swprintf_l", "swprintf"]
5+
api_name: ["__swprintf_l", "sprintf", "_sprintf_l", "_swprintf_l", "swprintf", "_swprintf"]
66
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ntdll.dll", "ucrtbase.dll", "ntoskrnl.exe"]
77
api_type: ["DLLExport"]
88
topic_type: ["apiref"]
9-
f1_keywords: ["_stprintf_l", "__swprintf_l", "sprintf_l", "swprintf", "_sprintf_l", "sprintf", "_stprintf", "stprintf_l"]
10-
helpviewer_keywords: ["_swprintf_l function", "_stprintf function", "__swprintf_l function", "stprintf function", "sprintf function", "_sprintf_l function", "_stprintf_l function", "swprintf function", "strings [C++], writing to", "_CRT_NON_CONFORMING_SWPRINTFS", "swprintf_l function", "stprintf_l function", "sprintf_l function", "formatted text [C++]"]
9+
f1_keywords: ["_stprintf_l", "__swprintf_l", "sprintf_l", "_swprintf", "swprintf", "_sprintf_l", "sprintf", "_stprintf", "stprintf_l"]
10+
helpviewer_keywords: ["_swprintf_l function", "_stprintf function", "__swprintf_l function", "stprintf function", "sprintf function", "_sprintf_l function", "_stprintf_l function", "swprintf function", "_swprintf function", "strings [C++], writing to", "_CRT_NON_CONFORMING_SWPRINTFS", "swprintf_l function", "stprintf_l function", "sprintf_l function", "formatted text [C++]"]
1111
---
12-
# `sprintf`, `_sprintf_l`, `swprintf`, `_swprintf_l`, `__swprintf_l`
12+
# `sprintf`, `_sprintf_l`, `swprintf`, `_swprintf`, `_swprintf_l`, `__swprintf_l`
1313

1414
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.
1515

@@ -21,37 +21,49 @@ int sprintf(
2121
const char *format [,
2222
argument] ...
2323
);
24+
2425
int _sprintf_l(
2526
char *buffer,
2627
const char *format,
2728
_locale_t locale [,
2829
argument] ...
2930
);
31+
3032
int swprintf(
3133
wchar_t *buffer,
3234
size_t count,
3335
const wchar_t *format [,
3436
argument]...
3537
);
38+
39+
int _swprintf(
40+
wchar_t *buffer,
41+
const wchar_t *format [,
42+
argument]...
43+
);
44+
3645
int _swprintf_l(
3746
wchar_t *buffer,
3847
size_t count,
3948
const wchar_t *format,
4049
_locale_t locale [,
4150
argument] ...
4251
);
52+
4353
int __swprintf_l(
4454
wchar_t *buffer,
4555
const wchar_t *format,
4656
_locale_t locale [,
4757
argument] ...
4858
);
59+
4960
template <size_t size>
5061
int sprintf(
5162
char (&buffer)[size],
5263
const char *format [,
5364
argument] ...
5465
); // C++ only
66+
5567
template <size_t size>
5668
int _sprintf_l(
5769
char (&buffer)[size],
@@ -97,7 +109,7 @@ The **`sprintf`** function formats and stores a series of characters and values
97109
98110
**`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.
99111

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.
101113

102114
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).
103115

@@ -113,7 +125,7 @@ In C++, these functions have template overloads that invoke the newer, secure co
113125
| Routine | Required header |
114126
|---|---|
115127
| **`sprintf`**, **`_sprintf_l`** | `<stdio.h>` |
116-
| **`swprintf`**, **`_swprintf_l`** | `<stdio.h>` or `<wchar.h>` |
128+
| **`swprintf`**, **`_swprintf`**, **`_swprintf_l`** | `<stdio.h>` or `<wchar.h>` |
117129

118130
For more compatibility information, see [Compatibility](../compatibility.md).
119131

0 commit comments

Comments
 (0)