*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> vprintf (3s)              
Title
Content
Arch
Section
 

Contents


VPRINTF(3S)							   VPRINTF(3S)


NAME    [Toc]    [Back]

     vprintf, vfprintf,	vsnprintf, vsprintf - print formatted output of	a
     variable argument list

SYNOPSIS    [Toc]    [Back]

     #include <stdarg.h>
     #include <stdio.h>

     int vprintf (const	char *format, va_list arg);

     int vfprintf (FILE	*stream, const char *format, va_list arg);

     int vsnprintf (char *s, size_t len, const char *format, va_list arg);

     int vsprintf (char	*s, const char *format,	va_list	arg);

DESCRIPTION    [Toc]    [Back]

     vprintf, vfprintf,	vsnprintf, and vsprintf	are the	same as	printf,
     fprintf, snprintf,	and sprintf respectively, except that instead of being
     called with a variable number of arguments, they are called with an
     argument list, arg, as defined by stdarg(5).  The arg parameter must be
     initialized by the	va_start macro (and possibly subsequent	va_arg calls).
     The vprintf, vfprintf, vsnprintf, and vsprintf functions do not invoke
     the va_end	macro.

EXAMPLE    [Toc]    [Back]

     The following demonstrates	the use	of vfprintf to write an	error routine.

     The stdarg.h header file defines the type va_list and a set of macros for
     advancing through a list of arguments whose number	and types may vary.
     The argument ap to	the vprint family of routines is of type va_list.
     This argument is used with	the stdarg.h header file macros	va_start,
     va_arg and	va_end [see va_start, va_arg, and va_end in stdarg(5)].

     #include <stdio.h>
     #include <stdarg.h>

     /*
      *	  error	should be called as:
      *	  error(function_name, format, arg1, arg2 ...);
      */
     void
     error(char	*function_name,	char *format, ...)
     {
	  va_list args;

	  va_start(args, format);
	  /* print out name of function	causing	error */
	  fprintf(stderr, "ERROR in %s:	", function_name);
	  /* print out remainder of message */
	  vfprintf(stderr, format, args);
	  va_end(args);



									Page 1






VPRINTF(3S)							   VPRINTF(3S)



     }

SEE ALSO    [Toc]    [Back]

      
      
     printf(3S), stdarg(5).

DIAGNOSTICS    [Toc]    [Back]

     vprintf, vfprintf,	vsnprintf, and vsprintf	return the number of
     characters	transmitted, or	return -1 if an	error was encountered.


									PPPPaaaaggggeeee 2222
[ Back ]
 Similar pages
Name OS Title
vfwprintf Tru64 Print formatted output for wide characters from stdarg parameter list
vswprintf Tru64 Print formatted output for wide characters from stdarg parameter list
vwprintf Tru64 Print formatted output for wide characters from stdarg parameter list
stdarg IRIX variable argument list
varargs IRIX variable argument list
varargs HP-UX handle variable argument list
varargs IRIX allow variable number of arguments in argument list
printf IRIX print formatted output
sprintf Tru64 Print formatted output
fprintf Tru64 Print formatted output
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service