#include <stdio.h>void setbuf(FILE * stream , char * buf );
The
setbuf( )
function specifies the buffer that
stream
will use or, if called with
buf
set to null, turns off buffering. If a programmer-defined buffer is to be specified, it must be
BUFSIZ
In C99, stream and buf are qualified by restrict .
Related functions are
fopen( )
,
fclose( )
, and
#include <stdio.h>int setvbuf(FILE * stream , char * buf , int mode , size_tsize );
The setvbuf( ) function allows the programmer to specify a buffer, its size, and its mode for the specified stream. The character array pointed to by buf is used as the buffer for I/O operations on stream . The size of the buffer is set by size and mode determines how buffering will be handled. If buf is null, setvbuf( ) will allocate its own buffer.
In C99, stream and buf are qualified by restrict .
The legal values of mode are _IOFBF , _IONBF , and _IOLBF . These are defined in < stdio.h >. When mode is set to _IOFBF , full buffering will take place. If mode is _IOLBF , the stream will be line buffered. For output streams, this means that the buffer will be flushed each time a newline character is written. The buffer is also flushed when full. For input streams, input is buffered until a newline is read. If mode is _IONBF , no buffering takes place.
The setvbuf( ) function returns zero on success and nonzero on failure.
A
#include <stdio.h>int snprintf(char * restrict buf , size_t num , const char * restrict format , ...)
The snprintf( ) function was added by C99.
The
snprintf( )
function is identical to
sprintf( )
except that a maximum of
num
–1
Related functions are printf( ) , sprintf( ) , and fsprintf( ) .
#include <stdio.h>int sprintf(char * buf , const char * format , ...);
The
sprintf( )
function is identical to
printf( )
except that the output is put into the array pointed to by
buf
instead of being written to the
In C99, buf and format are qualified by restrict .
The return value is equal to the number of
It is important to understand that
sprintf( )
provides no bounds checking on the array pointed to by
buf
. This means that the array will be
Related functions are printf( ) and fsprintf( ) .
#include <stdio.h>int sscanf(const char * buf , const char * format , ...);
The sscanf( ) function is identical to scanf( ) except that data is read from the array pointed to by buf rather than stdin . See scanf( ) .
In C99, buf and format are qualified by restrict .
The return value is equal to the number of
Related functions are scanf( ) and fscanf( ) .