[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


vprintf

Write formatted output to stdout.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stdio.h>
int vprintf(const char *format, va_list arg);
Parameters:

Parameters for this facility are:

format  
const char *  
The format string  
arg  
va_list  
A variable argument list  

Remarks:

The vprintf() function works identically to the printf() function. Instead of the variable list of arguments that can be passed to printf(), vprintf() accepts its arguments in the array of type va_list processed by the va_start() macro from the stdarg.h header file.

For specifications concerning the output control string and conversion specifiers please see: "Output Control String and Conversion Specifiers."

Return:

vprintf() returns the number of characters written or a negative value if it failed.

See Also:

"Wide Character and Byte Character Stream Orientation"

"fprintf"

"printf"

"Overview of stdarg.h"

Example of vprintf() usage.:
#include <stdio.h>
#include <stdarg.h>

int pr(char *, ...);

int main(void)
{
	int a = 56;
	double f = 483.582;
	static char s[] = "Metrowerks";

	// output a variable number of arguments to stdout
	pr("%15s %4.4f %-10d*\n", s, f, a);

	return 0;

}

// pr() formats and outputs a variable number of arguments
// to stdout using the vprintf() function
int pr(char *format, ...)
{
	va_list args;
	int retval;
	va_start(args, format); // prepare the arguments
	retval = vprintf(format, args);
	va_end(args);				// clean the stack
	return retval;
}

Output:
Metrowerks 483.5820 56        *


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000