Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > V

vprintf(3S)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

vprintf(), vfprintf(), vsprintf(), vsnprintf() — print formatted output of a varargs argument list

SYNOPSIS

#include <stdarg.h> #include <stdio.h> int vprintf(const char *__restrict format, va_list ap); int vfprintf(FILE *__restrict stream, const char *__restrict format, va_list ap); int vsprintf(char *__restrict s, const char *__restrict format, va_list ap); int vsnprintf(char *__restrict s, size_t maxsize, const char *__restrict format, va_list ap);

DESCRIPTION

vprintf(), vfprintf(), vsprintf(), and vsnprintf() are the same as printf(), fprintf(), sprintf(), and snprintf() respectively, except that instead of being called with a variable number of arguments, they are called with an argument list as defined by <stdarg.h>.

RETURN VALUE

Each function returns the number of bytes transmitted (excluding the \0 null byte character in the case of vsprintf()) or a negative value if an output error was encountered.

By default, vsnprintf() returns a negative value if maxsize is smaller than the number of characters formatted. In the UNIX 2003 standards environment (see standards(5)) it returns the number of bytes that would have been written to buffer s, excluding the terminating null byte, if maxsize had been sufficiently large.

EXAMPLES

The following demonstrates how vfprintf() could be used to write an error routine:

#include <stdarg.h> #include <stdio.h> . . . /* * error should be called using the form: * error(function_name, format, arg1, arg2...); */ /*VARARGS0*/ void error(va_alist) va_dcl { va_list args; char *fmt; va_start(args); /* print out name of function causing error */ (void)fprintf(stderr, "ERROR in %s: ", va_arg(args, char *)); fmt = va_arg(args, char *); /* print out remainder of message */ (void)vfprintf(stderr, fmt, args); va_end(args); (void)abort( ); }

STANDARDS CONFORMANCE

vprintf(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

vfprintf(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

vsprintf(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.