![]()  | 
   |
| << Previous | Next >> | |
|   |  |
int snprintf( char * buffer, int len, char * format, ... );
Description
- This function takes a string (pointed to by
 format), arguments of the format, and outputs the formatted string to the buffer pointed to bybuffer.snprintf()will only output up tolencharacters. The user should make sure that:
there are enough arguments after
formatto fill in the format parameters in the format stringthe types of arguments after
formatmatch the format fields informat
- For example,
 snprintf(buffer, BUF_LEN, "%s=%x","variable x",256);
- puts the string "variable x=100" into
 buffer.
- A complete list of valid conversion specifiers (%d, %s, etc.) can be found in the description for
 printf()under Dynamic C Conversion Specifiers.
- The macro
 STDIO_DISABLE_FLOATScan be defined if it is not necessary to format floating point numbers. If this macro is defined, %e, %f and %g will not be recognized. This can save thousands of bytes of code space.
- This function can be called by processes of different priorities.
 Parameters
- buffer
 
- Location of formatted string.
 
- len
 
- The maximum length of the formatted string.
 
- format
 
- String to be formatted.
 
- ...
 
- Format arguments.
 
Return value
- The number of characters written. If the output is truncated due to the
 lenparameter, then this function returns the number of characters that would have been written had there been enough space.Library
- STDIO.LIB
 See also
- printf, sprintf
 
| Dynamic C Functions | << Previous | Next >> | rabbit.com |