fprintf_s formats and prints a series of characters and values to the output stream. Each function argument (if any) is converted and output according to the corresponding format specification in format. For fprintf_s, the format argument has the same syntax and use that it has in printf_s.
fwprintf_s is a wide-character version of fprintf_s; in fwprintf_s, format is a wide-character string. These functions behave identically if the stream is opened in ANSI mode. fprintf_s doesn't currently support output into a UNICODE stream.
The versions of these functions with the _l suffix are identical except that they use the locale parameter passed in instead of the current locale.
Security Note |
|---|
| Ensure that format is not a user-defined string. |
Like the non-secure versions (see fprintf, _fprintf_l, fwprintf, _fwprintf_l), these functions validate their parameters and invoke the invalid parameter handler, as described in Parameter Validation, if either stream or format is a null pointer. These functions differ from the non-secure versions in that the format string itself is also validated. If there are any unknown or badly formed formatting specifiers, these functions generate the invalid parameter exception. In all cases, If execution is allowed to continue, the functions return -1 and set errno to EINVAL. See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, error codes.
Generic-Text Routine Mappings
|
TCHAR.H routine
|
_UNICODE & _MBCS not defined
|
_MBCS defined
|
_UNICODE defined
|
| _ftprintf_s | fprintf_s | fprintf_s | fwprintf_s |
| _ftprintf_s_l | _fprintf_s_l | _fprintf_s_l | _fwprintf_s_l |
For more information, see Format Specifications.