473,506 Members | 16,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing variable length arguements to another function.

Hi,

Given the following function:-

void foo (char *fmt, ...) {
}

I know how to use va_start, va_end etc to process the parameters but is
there an easy way of passing the parameter list onto another function
that also has variable length arguements.

So for example given the function

void bar (char *fmt, ....) {
}

can I call bar from foo such as

void foo (char *fmt, ...) {
bar (fmt, <what goes here>);
}

Thanks
Andy

Nov 14 '05 #1
3 1739


ju**@andy-coleman.co.uk wrote:
Hi,

Given the following function:-

void foo (char *fmt, ...) {
}

I know how to use va_start, va_end etc to process the parameters but is
there an easy way of passing the parameter list onto another function
that also has variable length arguements.


This is Question 15.12 in the comp.lang.c Frequently
Asked Questions (FAQ) list

http://www.eskimo.com/~scs/C-faq/top.html

--
Er*********@sun.com

Nov 14 '05 #2
ju**@andy-coleman.co.uk wrote:
Hi,

Given the following function:-

void foo (char *fmt, ...) {
}

I know how to use va_start, va_end etc to process the parameters but is
there an easy way of passing the parameter list onto another function
that also has variable length arguements.

So for example given the function

void bar (char *fmt, ....) {
}

can I call bar from foo such as

void foo (char *fmt, ...) {
bar (fmt, <what goes here>);
}

Thanks
Andy

No. You should call the function bar with a va_list from function foo.

Krishanu
Nov 14 '05 #3
In article <cu**********@news1brm.Central.Sun.COM>,
Eric Sosman <er*********@sun.com> wrote:


ju**@andy-coleman.co.uk wrote:
Hi,

Given the following function:-

void foo (char *fmt, ...) {
}

I know how to use va_start, va_end etc to process the parameters but is
there an easy way of passing the parameter list onto another function
that also has variable length arguements.


This is Question 15.12 in the comp.lang.c Frequently
Asked Questions (FAQ) list

http://www.eskimo.com/~scs/C-faq/top.html


The short summary of which is: No. That's why the v*printf() functions
exist. I.e., you have to provide v* versions of your functions that accept
va_arg type args (rather than the usual list of args).

Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
6508
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
3
14907
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
58
10048
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
11
4431
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
1
11847
by: | last post by:
Hi, 1st, I did a search and could not find any info on this, the Google results were good, but I'm still have issues...So any help will be great. I have a frame page, which contains 3 frames...
6
5563
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
12
2662
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
2
1946
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would...
1
2199
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would call...
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.