Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail |
|---|---|
| NNTP-Posting-Date | Sun, 20 Nov 2011 12:33:56 -0600 |
| Message-ID | <4EC94804.4E9F@mindspring.com> (permalink) |
| Date | Sun, 20 Nov 2011 13:33:40 -0500 |
| From | pete <pfiland@mindspring.com> |
| Reply-To | pfiland@mindspring.com |
| Organization | PF |
| X-Mailer | Mozilla 3.04Gold (WinNT; I) |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.c |
| Subject | Re: Variable argument function as a parameter of a variable argument function |
| References | <00f0752d-f768-437a-87c5-0b3767c7411f@l24g2000yqm.googlegroups.com> |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| Lines | 61 |
| X-Usenet-Provider | http://www.giganews.com |
| NNTP-Posting-Host | 4.154.218.83 |
| X-Trace | sv3-9SRWJhcbZPBSa/rICG6VAWOmawWy4Tz2UXsREBHOovML8QJhHaG0+tAHTFuXjaqUIjMhwqhp50hufkP!r6Ic2oRsDsquQ9kfkSpTKzVrT6so+Lxv81Z6I6BkET2xgGO8tMGOHFde5hEyVQl9/ESgU38j4sdj!kiwwm/xjoQ== |
| X-Abuse-and-DMCA-Info | Please be sure to forward a copy of ALL headers |
| X-Abuse-and-DMCA-Info | Otherwise we will be unable to process your complaint properly |
| X-Postfilter | 1.3.40 |
| X-Original-Bytes | 2378 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c:13646 |
Show key headers only | View raw
AikidoGuy wrote:
>
> Hi everyone,
>
> I've done a little searching, but I can't quite find an answer to my
> question. Everything I've found is more related to how to construct a
> variable argument function, and that's not my question.
>
> Suppose I have a variable argument function. Is it possible to use it
> to initialize a parameter of another variable argument function?
>
> For example, printf("%s", varArgFcnReturningAString(a,b,c));
>
> I ask because I'm not sure if this is supported by the standard and/or
> could be compiler specific.
>
> Thank you for any help, tips, and suggestions!
/* BEGIN output from new.c */
Yes, it is possible.
/* END output from new.c */
/* BEGIN new.c */
#include <stdio.h>
#include <stdarg.h>
char *varArgFcnReturningAString(char *s, const char *format, ...)
{
va_list arg;
va_start(arg, format);
vsprintf(s, format, arg);
va_end(arg);
return s;
}
int
main(void)
{
char *b = "%s";
char c[] = "Yes, it is possible.";
char a[sizeof c] = {0};
puts("\n/* BEGIN output from new.c */\n");
printf("%s", varArgFcnReturningAString(a, b, c));
puts("\n\n/* END output from new.c */");
return 0;
}
--
pete
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Variable argument function as a parameter of a variable argument function AikidoGuy <aikidoguy@gmail.com> - 2011-11-19 23:02 -0800
Re: Variable argument function as a parameter of a variable argument function Ark <akhasin@macroexpressions.com> - 2011-11-20 03:14 -0500
Re: Variable argument function as a parameter of a variable argument function Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-20 08:07 -0500
Re: Variable argument function as a parameter of a variable argument function Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-20 08:11 -0500
Re: Variable argument function as a parameter of a variable argument function Keith Thompson <kst-u@mib.org> - 2011-11-20 08:19 -0800
Re: Variable argument function as a parameter of a variable argument function pete <pfiland@mindspring.com> - 2011-11-20 13:33 -0500
Re: Variable argument function as a parameter of a variable argument function AikidoGuy <aikidoguy@gmail.com> - 2011-11-20 15:29 -0800
Re: Variable argument function as a parameter of a variable argument function Keith Thompson <kst-u@mib.org> - 2011-11-20 15:58 -0800
Re: Variable argument function as a parameter of a variable argument function AikidoGuy <aikidoguy@gmail.com> - 2011-11-20 16:05 -0800
Re: Variable argument function as a parameter of a variable argument function James Kuyper <jameskuyper@verizon.net> - 2011-11-20 20:45 -0500
Re: Variable argument function as a parameter of a variable argument function AikidoGuy <aikidoguy@gmail.com> - 2011-11-20 20:18 -0800
Re: Variable argument function as a parameter of a variable argument function James Kuyper <jameskuyper@verizon.net> - 2011-11-21 07:22 -0500
Re: Variable argument function as a parameter of a variable argument function Seebs <usenet-nospam@seebs.net> - 2011-11-21 22:43 +0000
csiph-web