INtime SDK Help
sprintf, sprintf_s, swprintf, swprintf_s

Prints formatted data to a string.

#include <stdio.h>

int sprintf (char *buffer, const char *format[, argument]...);
int sprintf_s(char *buffer, rsize_t buflen, const char *format[, argument]...);

#include <wchar.h>

int swprintf(wchar_t *buffer, size_t buflen, const wchar_t *format[, argument]...);
int swprintf_s(wchar_t *buffer, size_t buflen, const wchar_t *format[, argument]...);

Parameters

buffer
Output string.
buflen
The maximum number of characters to store.
format
Formatted string consisting of ordinary characters, escape sequences, and, if arguments appear, format specifications. The format and optional arguments have the same form and function as printf.
argument
Optional argument or arguments.

Return Values

The number of characters stored in buffer, not counting the terminating null character.

Remarks

The ordinary characters and escape sequences are copied to buffer in order of their appearance.

A null character \0 is appended to the end of the characters written.

sprintf_s performs additional parameter validation comapred with sprintf.

The other main difference between sprintf_s and sprintf is that sprintf_s takes a length parameter specifying the size of the output buffer in characters. If the buffer is too small for the text being printed then the buffer is set to an empty string and the invalid parameter handler is invoked. Unlike snprintf, sprintf_s guarantees that the buffer will be null-terminated (unless the buffer size is zero).

swprintf and swprintf_s are the wide-character versions of sprintf and sprintf_s.

Generic Text Routines

tchar.h routine _UNICODE not defined _UNICODE defined
__stprintf sprintf swprintf
_stprintf_s sprintf_s swprintf_s

Requirements

Versions Defined in Include Link to
INtime 3.0
INtime 6.0 (wide-character and generic text versions)
intime/rt/include/stdio.h
intime/rt/include/wchar.h
intime/rt/include/tchar.h
stdio.h
wchar.h
tchar.h
clib.lib
   
See Also