Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | jononanon@googlemail.com |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | va_arg... recursion: changing arguments and the using recursion |
| Date | 2012-04-25 11:02 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <6923270.398.1335376959698.JavaMail.geo-discussion-forums@vbcg6> (permalink) |
Hello...
is there a nice and portable way of changing some variable arguments, and then passing these changed arguments to the same function as recursion??
Here's a non-general example:
#include <stdio.h>
int go(int num, ...)
{
int *p = #
int *p2 = p;
int i, n;
for (i = 1; i <= num; ++i)
printf("%d ", *(++p2));
putchar('\n');
for (p2 = p+num; p2 > p; --p2) {
n = *(p2);
if (n > 0) {
--(*p2);
//recurr
p2 = p+1;
go(num, *p2, *(p2+1), *(p2+2)); // lucky me... 4 total arguments
break;
}
}
}
int main(void)
{
go(3, 3, 3, 3);
return 0;
}
As is shown in the comment above, I'm just lucky with invoking 4 arguments in the recursion.
What could I do, if I don't know the number of arguments and want recursion?
Thanks.
Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread
va_arg... recursion: changing arguments and the using recursion jononanon@googlemail.com - 2012-04-25 11:02 -0700
Re: va_arg... recursion: changing arguments and the using recursion jononanon@googlemail.com - 2012-04-25 11:16 -0700
Re: va_arg... recursion: changing arguments and the using recursion James Kuyper <jameskuyper@verizon.net> - 2012-04-26 14:08 -0400
Re: va_arg... recursion: changing arguments and the using recursion jononanon@googlemail.com - 2012-04-26 12:44 -0700
Re: va_arg... recursion: changing arguments and the using recursion John Reye <jononanon@googlemail.com> - 2012-04-26 13:02 -0700
Re: va_arg... recursion: changing arguments and the using recursion John Reye <jononanon@googlemail.com> - 2012-04-26 13:13 -0700
Re: va_arg... recursion: changing arguments and the using recursion James Kuyper <jameskuyper@verizon.net> - 2012-04-26 16:28 -0400
Re: va_arg... recursion: changing arguments and the using recursion James Kuyper <jameskuyper@verizon.net> - 2012-04-26 16:34 -0400
Re: va_arg... recursion: changing arguments and the using recursion John Reye <jononanon@googlemail.com> - 2012-04-26 13:37 -0700
csiph-web