Zilog ZUSBOPTS Manual do Utilizador Página 483

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
Vista de página 482
UM017105-0511 Standard Functions
Zilog Developer Studio II – ZNEO™
User Manual
455
Synopsis
#include <stdarg.h>
void va_end(va_list ap);
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, ...);
va_start
Is executed before any access to the unnamed arguments.
The parameter
ap points to an object that has type va_list. The parameter parmN is the
identifier of the rightmost parameter in the variable parameter list in the function defini-
tion (the one just before the , ...). The
va_start macro initializes ap for subsequent use
by
va_arg and va_end.
Synopsis
#include <stdarg.h>
void va_start(va_list ap, parmN);
Vista de página 482
1 2 ... 478 479 480 481 482 483 484 485 486 487 488 ... 519 520

Comentários a estes Manuais

Sem comentários