Sun Java System Web Server 7.0 Update 2 NSAPI Developer's Guide

util_sprintf() Function

The util_sprintf function formats a specified string, using a specified format, into a specified buffer, using the printf-style syntax without bounds checking. This function returns the number of characters in the formatted buffer.

Because util_sprintf does not perform bounds checking, use this function only if you are certain that the string fits the buffer. Otherwise, use the function util_snprintf. For more information, see the documentation on the printf function for the runtime library of your compiler.

Syntax

int util_sprintf(char *s, char *fmt, ...);

Return Values

The number of characters formatted into the buffer.

Parameters

char *s is the buffer to receive the formatted string.

char *fmt is the format string. The function handles only %d and %s strings. The function does not handle any width or precision strings.

... represents a sequence of parameters for the printf function.

Example

char *logmsg;
int len;
logmsg = (char *) MALLOC(256);
len = util_sprintf(logmsg, "%s %s %s\n", ip, method, uri);

See Also

util_snprintf() Function, util_vsnprintf() Function, util_vsprintf() Function