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 output using a pointer to a list of arguments. More secure versions of these functions are available; see [vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l](../../c-runtime-library/reference/vsprintf-s-vsprintf-s-l-vswprintf-s-vswprintf-s-l.md).
25
-
26
-
## Syntax
27
-
28
-
```
29
-
int vsprintf(
30
-
char *buffer,
31
-
const char *format,
32
-
va_list argptr
33
-
);
34
-
int _vsprintf_l(
35
-
char *buffer,
36
-
const char *format,
37
-
locale_t locale,
38
-
va_list argptr
39
-
);
40
-
int vswprintf(
41
-
wchar_t *buffer,
42
-
size_t count,
43
-
const wchar_t *format,
44
-
va_list argptr
45
-
);
46
-
int _vswprintf_l(
47
-
wchar_t *buffer,
48
-
size_t count,
49
-
const wchar_t *format,
50
-
locale_t locale,
51
-
va_list argptr
52
-
);
53
-
int __vswprintf_l(
54
-
wchar_t *buffer,
55
-
const wchar_t *format,
56
-
locale_t locale,
57
-
va_list argptr
58
-
);
59
-
template <size_t size>
60
-
int vsprintf(
61
-
char (&buffer)[size],
62
-
const char *format,
63
-
va_list argptr
64
-
); // C++ only
65
-
template <size_t size>
66
-
int _vsprintf_l(
67
-
char (&buffer)[size],
68
-
const char *format,
69
-
locale_t locale,
70
-
va_list argptr
71
-
); // C++ only
72
-
template <size_t size>
73
-
int vswprintf(
74
-
wchar_t (&buffer)[size],
75
-
const wchar_t *format,
76
-
va_list argptr
77
-
); // C++ only
78
-
template <size_t size>
79
-
int _vswprintf_l(
80
-
wchar_t (&buffer)[size],
81
-
const wchar_t *format,
82
-
locale_t locale,
83
-
va_list argptr
84
-
); // C++ only
85
-
```
86
-
87
-
#### Parameters
88
-
`buffer`
89
-
Storage location for output.
90
-
91
-
`count`
92
-
Maximum number of characters to store, in the `UNICODE` version of this function.
93
-
94
-
`format`
95
-
Format specification.
96
-
97
-
`argptr`
98
-
Pointer to list of arguments.
99
-
100
-
`locale`
101
-
The locale to use.
102
-
103
-
## Return Value
104
-
`vsprintf` and `vswprintf` return the number of characters written, not including the terminating null character, or a negative value if an output error occurs. If `buffer` or `format` is a null pointer, these functions invoke the invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, these functions return -1 and set `errno` to `EINVAL`.
105
-
106
-
For information on these and other error codes, see [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
107
-
108
-
## Remarks
109
-
Each of these functions takes a pointer to an argument list, and then formats and writes the given data to the memory pointed to by `buffer`.
110
-
111
-
The versions of these functions with the `_l` suffix are identical except that they use the locale parameter passed in instead of the current thread locale.
112
-
113
-
> [!IMPORTANT]
114
-
> Using `vsprintf`, here is no way to limit the number of characters written, which means that code using this function is susceptible to buffer overruns. Use [_vsnprintf](../../c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md) instead, or call [_vscprintf](../../c-runtime-library/reference/vscprintf-vscprintf-l-vscwprintf-vscwprintf-l.md) to determine how large a buffer is needed. Also, ensure that `format` is not a user-defined string. For more information, see [Avoiding Buffer Overruns](http://msdn.microsoft.com/library/windows/desktop/ms717795).
115
-
116
-
`vswprintf` 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.` The old behavior may not be in a future version, so code should be changed to use the new conformant behavior.
117
-
118
-
In C++, these functions have template overloads that invoke the newer, secure counterparts of these functions. For more information, see [Secure Template Overloads](../../c-runtime-library/secure-template-overloads.md).
119
-
120
-
### Generic-Text Routine Mappings
121
-
122
-
|TCHAR.H routine|_UNICODE & _MBCS not defined|_MBCS defined|_UNICODE defined|
Write formatted output using a pointer to a list of arguments. More secure versions of these functions are available; see [vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l](../../c-runtime-library/reference/vsprintf-s-vsprintf-s-l-vswprintf-s-vswprintf-s-l.md).
25
+
26
+
## Syntax
27
+
28
+
```
29
+
int vsprintf(
30
+
char *buffer,
31
+
const char *format,
32
+
va_list argptr
33
+
);
34
+
int _vsprintf_l(
35
+
char *buffer,
36
+
const char *format,
37
+
locale_t locale,
38
+
va_list argptr
39
+
);
40
+
int vswprintf(
41
+
wchar_t *buffer,
42
+
size_t count,
43
+
const wchar_t *format,
44
+
va_list argptr
45
+
);
46
+
int _vswprintf_l(
47
+
wchar_t *buffer,
48
+
size_t count,
49
+
const wchar_t *format,
50
+
locale_t locale,
51
+
va_list argptr
52
+
);
53
+
int __vswprintf_l(
54
+
wchar_t *buffer,
55
+
const wchar_t *format,
56
+
locale_t locale,
57
+
va_list argptr
58
+
);
59
+
template <size_t size>
60
+
int vsprintf(
61
+
char (&buffer)[size],
62
+
const char *format,
63
+
va_list argptr
64
+
); // C++ only
65
+
template <size_t size>
66
+
int _vsprintf_l(
67
+
char (&buffer)[size],
68
+
const char *format,
69
+
locale_t locale,
70
+
va_list argptr
71
+
); // C++ only
72
+
template <size_t size>
73
+
int vswprintf(
74
+
wchar_t (&buffer)[size],
75
+
const wchar_t *format,
76
+
va_list argptr
77
+
); // C++ only
78
+
template <size_t size>
79
+
int _vswprintf_l(
80
+
wchar_t (&buffer)[size],
81
+
const wchar_t *format,
82
+
locale_t locale,
83
+
va_list argptr
84
+
); // C++ only
85
+
```
86
+
87
+
#### Parameters
88
+
`buffer`
89
+
Storage location for output.
90
+
91
+
`count`
92
+
Maximum number of characters to store, in the `UNICODE` version of this function.
93
+
94
+
`format`
95
+
Format specification.
96
+
97
+
`argptr`
98
+
Pointer to list of arguments.
99
+
100
+
`locale`
101
+
The locale to use.
102
+
103
+
## Return Value
104
+
`vsprintf` and `vswprintf` return the number of characters written, not including the terminating null character, or a negative value if an output error occurs. If `buffer` or `format` is a null pointer, these functions invoke the invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, these functions return -1 and set `errno` to `EINVAL`.
105
+
106
+
For information on these and other error codes, see [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
107
+
108
+
## Remarks
109
+
Each of these functions takes a pointer to an argument list, and then formats and writes the given data to the memory pointed to by `buffer`.
110
+
111
+
The versions of these functions with the `_l` suffix are identical except that they use the locale parameter passed in instead of the current thread locale.
112
+
113
+
> [!IMPORTANT]
114
+
> Using `vsprintf`, there is no way to limit the number of characters written, which means that code using this function is susceptible to buffer overruns. Use [_vsnprintf](../../c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md) instead, or call [_vscprintf](../../c-runtime-library/reference/vscprintf-vscprintf-l-vscwprintf-vscwprintf-l.md) to determine how large a buffer is needed. Also, ensure that `format` is not a user-defined string. For more information, see [Avoiding Buffer Overruns](http://msdn.microsoft.com/library/windows/desktop/ms717795).
115
+
116
+
`vswprintf` 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.` The old behavior may not be in a future version, so code should be changed to use the new conformant behavior.
117
+
118
+
In C++, these functions have template overloads that invoke the newer, secure counterparts of these functions. For more information, see [Secure Template Overloads](../../c-runtime-library/secure-template-overloads.md).
119
+
120
+
### Generic-Text Routine Mappings
121
+
122
+
|TCHAR.H routine|_UNICODE & _MBCS not defined|_MBCS defined|_UNICODE defined|
0 commit comments