On Sun, 07 Dec 2003 01:38:51 -0700, in comp.lang.c , Jeff Rodriguez
<ne********@gurugeek.EXAMPLENOSPAM.com> wrote:
How does one go about creating and accessing the arguments of a function like this?
Read up on va_args. va_start, va_end etc in stdarg.h.
The ISO standard has this example on page 264 which may or may not
make sense to you.
#include <stdarg.h>
#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);
}
You might want to find an opensource version of printf to examine for
some further tips eg handling different types of parameter.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---