Skip to content

Commit a605e47

Browse files
huypubTylerMSFTprmerger-automator[bot]
authored
3/09 AM Publish (#4839)
* add _swprintf * typo * fix github issue #4442 --------- Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com> Co-authored-by: prmerger-automator[bot] <40007230+prmerger-automator[bot]@users.noreply.github.com>
1 parent 87051bf commit a605e47

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

docs/c-runtime-library/reference/getch-getwch.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "_getch, _getwch"
33
description: "API reference for _getch and _getwch; which get a character from the console without echo."
4-
ms.date: "4/2/2020"
4+
ms.date: "3/8/2023"
55
api_name: ["_getch", "_getwch", "_o__getch", "_o__getwch"]
66
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-conio-l1-1-0.dll"]
77
api_type: ["DLLExport"]
@@ -29,7 +29,7 @@ Returns the character read. There's no error return.
2929
3030
## Remarks
3131
32-
The **`_getch`** and **`_getwch`** functions read a single character from the console without echoing the character. None of these functions can be used to read CTRL+C. To read a function key or arrow key, each function must be called twice. The first call returns `0` or `0xE0`. The second call returns the [key scan code](/previous-versions/visualstudio/visual-studio-6.0/aa299374(v=vs.60)).
32+
The **`_getch`** and **`_getwch`** functions read a single character from the console without echoing the character. To read a function key or arrow key, each function must be called twice. The first call returns `0` or `0xE0`. The second call returns the [key scan code](/previous-versions/visualstudio/visual-studio-6.0/aa299374(v=vs.60)).
3333
3434
These functions lock the calling thread and so are thread-safe. For non-locking versions, see [`_getch_nolock`, `_getwch_nolock`](getch-nolock-getwch-nolock.md).
3535

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy