1
1
---
2
2
title : " vsprintf, _vsprintf_l, vswprintf, _vswprintf_l, __vswprintf_l"
3
- ms.date : " 11/04/2016 "
3
+ ms.date : " 09/03/2019 "
4
4
apiname : ["_vswprintf_l", "_vsprintf_l", "vsprintf", "vswprintf", "__vswprintf_l"]
5
5
apilocation : ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "ntoskrnl.exe"]
6
6
apitype : " DLLExport"
@@ -75,19 +75,19 @@ int _vswprintf_l(
75
75
76
76
### Parameters
77
77
78
- * buffer* < br />
78
+ * buffer* \
79
79
Storage location for output.
80
80
81
- * count* < br />
81
+ * count* \
82
82
Maximum number of characters to store, in the wide string versions of this function.
83
83
84
- * format* < br />
84
+ * format* \
85
85
Format specification.
86
86
87
- * argptr* < br />
87
+ * argptr* \
88
88
Pointer to list of arguments.
89
89
90
- * locale* < br />
90
+ * locale* \
91
91
The locale to use.
92
92
93
93
## Return Value
@@ -131,15 +131,16 @@ For additional compatibility information, see [Compatibility](../../c-runtime-li
131
131
132
132
``` C
133
133
// crt_vsprintf.c
134
- // compile with: /W3
134
+ // compile with: cl /W4 crt_vsprintf.c
135
135
// This program uses vsprintf to write to a buffer.
136
136
// The size of the buffer is determined by _vscprintf.
137
137
138
+ #define _CRT_SECURE_NO_WARNINGS
138
139
#include < stdlib.h>
139
140
#include < stdio.h>
140
141
#include < stdarg.h>
141
142
142
- void test ( char * format, ... )
143
+ void test ( char const * const format, ... )
143
144
{
144
145
va_list args;
145
146
int len;
@@ -152,12 +153,14 @@ void test( char * format, ... )
152
153
+ 1; // terminating '\0'
153
154
154
155
buffer = (char*)malloc( len * sizeof(char) );
155
-
156
- vsprintf( buffer, format, args ); // C4996
157
- // Note: vsprintf is deprecated; consider using vsprintf_s instead
158
- puts( buffer );
159
-
160
- free( buffer );
156
+ if ( 0 != buffer )
157
+ {
158
+ vsprintf( buffer, format, args ); // C4996
159
+ // Note: vsprintf is deprecated; consider using vsprintf_s instead
160
+ puts( buffer );
161
+
162
+ free( buffer );
163
+ }
161
164
va_end( args );
162
165
}
163
166
@@ -175,10 +178,10 @@ This is a string
175
178
176
179
## See also
177
180
178
- [ Stream I/O] ( ../../c-runtime-library/stream-i-o.md ) < br />
179
- [ vprintf Functions] ( ../../c-runtime-library/vprintf-functions.md ) < br />
180
- [ Format Specification Syntax: printf and wprintf Functions] ( ../../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md ) < br />
181
- [ fprintf, _ fprintf_l, fwprintf, _ fwprintf_l] ( fprintf-fprintf-l-fwprintf-fwprintf-l.md ) < br />
182
- [ printf, _ printf_l, wprintf, _ wprintf_l] ( printf-printf-l-wprintf-wprintf-l.md ) < br />
183
- [ sprintf, _ sprintf_l, swprintf, _ swprintf_l, \_ _ swprintf_l] ( sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md ) < br />
184
- [ va_arg, va_copy, va_end, va_start] ( va-arg-va-copy-va-end-va-start.md ) < br />
181
+ [ Stream I/O] ( ../../c-runtime-library/stream-i-o.md ) \
182
+ [ vprintf Functions] ( ../../c-runtime-library/vprintf-functions.md ) \
183
+ [ Format Specification Syntax: printf and wprintf Functions] ( ../../c-runtime-library/format-specification-syntax-printf-and-wprintf-functions.md ) \
184
+ [ fprintf, _ fprintf_l, fwprintf, _ fwprintf_l] ( fprintf-fprintf-l-fwprintf-fwprintf-l.md ) \
185
+ [ printf, _ printf_l, wprintf, _ wprintf_l] ( printf-printf-l-wprintf-wprintf-l.md ) \
186
+ [ sprintf, _ sprintf_l, swprintf, _ swprintf_l, \_ _ swprintf_l] ( sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md ) \
187
+ [ va_arg, va_copy, va_end, va_start] ( va-arg-va-copy-va-end-va-start.md )
0 commit comments