 | Cx51 User's Guide |  |
|
|
| sprintf517| Summary |
#include <80c517.h>
int sprintf517 (
char *buffer, /* storage buffer */
const char *fmtstr /* format string */
<[>, arguments ...<]>); /* additional arguments */
| | Description | The sprintf517 function formats a series of strings and numeric values and stores the resulting string in buffer. This function is similar to the printf routine, but it stores the formatted output in a buffer rather than send it to the output stream. The fmtstr argument is a pointer to a format string which has the same form and function as the printf function's format string. The list of arguments are converted and output according to the corresponding format specifications in fmtstr. Note - The total number of bytes that may be passed to this function is limited due to the memory restrictions imposed by the 8051. A maximum of 15 bytes may be passed in SMALL or COMPACT model. A maximum of 40 bytes may be passed in LARGE model.
- This routine uses the arithmetic unit of the Infineon C517x/C509 to provide accelerated execution speed. Do not use this routine with a CPU that does not support this feature.
| | Return Value | The sprintf517 function returns the number of characters actually written to buffer. | | See Also | gets, printf, printf517, puts, scanf, scanf517, sscanf, sscanf517, vprintf, vsprintf | | Example |
#include <80c517.h>
#include <stdio.h> /* for puts */
void tst_sprintf517 (void) {
char buf [100];
int n;
int a,b;
float pi;
a = 123;
b = 456;
pi = 3.14159;
n = sprintf517 (buf, "%f\n", 1.1);
n += sprintf517 (buf+n, "%d\n", a);
n += sprintf517 (buf+n, "%d %s %g", b, "---", pi);
puts (buf);
}
|
|
|