public member function
<streambuf> <iostream>


streamsize xsputn (const char_type* s, streamsize n);
Put sequence of characters
Writes characters from the array pointed to by s into the controlled output sequence, until either n characters have been written or the end of the output sequence is reached.

Its default behavior in basic_streambuf is to call sputc n times, stopping if any call returns traits_type::eof().
Its default behavior in basic_streambuf is to retrieve n characters, as if calling sputc for each, stopping if any call would return traits_type::eof(). Except it is unspecified whether member overflow is called or whether other means are used in case of overflows.

This is a virtual member function, and derived classes may provide a more efficient implementation.


Pointer to the sequence of characters to be written.
Member type char_type is the type of the characters in the stream buffer (the first class template parameter).
Number of characters to write.
This shall be a non-negative value.
streamsize is a signed integral type.

Return Value

The number of characters written.
streamsize is a signed integral type.

Data races

Accesses up to all of the first n characters in the array pointed by s.
Modifies the stream buffer object.
Concurrent access to the same array or to the same stream buffer object may introduce data races.

Exception safety

Basic guarantee: if an exception is thrown, the stream buffer is in a valid state (this also applies to standard derived classes).

Invalid arguments cause undefined behavior.

See also