swprintf

Writes wide-character output to a specified character array under format control.

Library:LibC
Classification:ANSI
Service:Characters and Strings

Syntax

  #include <wchar.h> 
   
  int  swprintf (
     wchar_t         *ws,
     size_t           n,
     const wchar_t   *format,
     ...);
  

Parameters

ws

(OUT) Points to the character array into which to place the output. The array always ends in a NULL wide character unless the n parameter is zero.

n

(IN) Specifies the number of characters to output.

format

(IN) Points to the format control string. See Section 12.4, Wide-Character Print Format Control Strings.

...

(IN) Points to an argument for a conversion specifier. The number of arguments is determined by the format string.

Return Values

If successful, returns the number of characters written. Otherwise, returns a negative value and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

The file descriptor is not a valid file descriptor open for writing.

5

ENOMEM

Insufficient storage space is available.

9

EINVAL

The format string contains insufficient arguments.

12

ENOSPC

No free space remains on the device containing the file.

24

EAGAIN

The O_NONBLOCK flag is set for the file descriptor, and the process cannot immediately perform the write operation.

28

EIO

A physical I/O error has occurred.

32

EPIPE

An attempt was made to write to a pipe or FIFO that is not open for reading by any process.

63

EINTR

A signal interrupted the write operation.

71

EFBIG

An attempt was made to write to a file that exceeds the maximum file size.

101

EILSEQ

A wide-character code that does not correspond to a valid character has been detected.

Remarks

The swprintf function is equivalent to fwprintf, except that the ws parameter specifies a character array into which the generated output is placed, rather than a file. If the n parameter is not zero, a NULL character is placed at the end of the character array.

See Also