11---
22title : " vsprintf, _vsprintf_l, vswprintf, _vswprintf_l, __vswprintf_l"
3- ms.date : " 11/04/2016 "
3+ ms.date : " 09/03/2019 "
44apiname : ["_vswprintf_l", "_vsprintf_l", "vsprintf", "vswprintf", "__vswprintf_l"]
55apilocation : ["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"]
66apitype : " DLLExport"
@@ -75,19 +75,19 @@ int _vswprintf_l(
7575
7676### Parameters
7777
78- * buffer* < br />
78+ * buffer* \
7979Storage location for output.
8080
81- * count* < br />
81+ * count* \
8282Maximum number of characters to store, in the wide string versions of this function.
8383
84- * format* < br />
84+ * format* \
8585Format specification.
8686
87- * argptr* < br />
87+ * argptr* \
8888Pointer to list of arguments.
8989
90- * locale* < br />
90+ * locale* \
9191The locale to use.
9292
9393## Return Value
@@ -131,15 +131,16 @@ For additional compatibility information, see [Compatibility](../../c-runtime-li
131131
132132``` C
133133// crt_vsprintf.c
134- // compile with: /W3
134+ // compile with: cl /W4 crt_vsprintf.c
135135// This program uses vsprintf to write to a buffer.
136136// The size of the buffer is determined by _vscprintf.
137137
138+ #define _CRT_SECURE_NO_WARNINGS
138139#include < stdlib.h>
139140#include < stdio.h>
140141#include < stdarg.h>
141142
142- void test ( char * format, ... )
143+ void test ( char const * const format, ... )
143144{
144145 va_list args;
145146 int len;
@@ -152,12 +153,14 @@ void test( char * format, ... )
152153 + 1; // terminating '\0'
153154
154155 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+ }
161164 va_end( args );
162165}
163166
@@ -175,10 +178,10 @@ This is a string
175178
176179## See also
177180
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