Zilog ZUSBOPTS Manual do Utilizador Página 484

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
Vista de página 483
Standard Functions UM017105-0511
456
Zilog Developer Studio II – ZNEO™
User Manual
Example
The function f1 gathers into an array a list of arguments that are pointers to strings (but not
more than MAXARGS arguments), then passes the array as a single argument to function
f2. The number of pointers is specified by the first argument to f1.
#include <stdarg.h>
extern void f2(int n, char *array[]);
#define MAXARGS 31
void f1(int n_ptrs,...) {
va_list ap;
char *array[MAXARGS];
int ptr_no = 0;
if (n_ptrs > MAXARGS)
n_ptrs = MAXARGS;
va_start(ap, n_ptrs);
while (ptr_no < n_ptrs)
array[ptr_no++] = va_arg(ap, char *);
va_end(ap);
f2(n_ptrs, array);
}
Each call to f1 has in scope the definition of the function of a declaration such as void
f1(int, ...);
vprintf
Equivalent to printf, with the variable argument list replaced by arg, which has been ini-
tialized by the
va_start macro (and possibly subsequent va_arg calls). The vprintf
function does not invoke the
va_end function.
Synopsis
#include <stdarg.h>
#include <stdio.h>
int vprintf(const char *format, va_list arg);
Returns
The number of characters transmitted or a negative value if an output error occurred.
Example
va_list va;
/* initialize the variable argument va here */
vprintf("%d %d %d",va);
Vista de página 483
1 2 ... 479 480 481 482 483 484 485 486 487 488 489 ... 519 520

Comentários a estes Manuais

Sem comentários