how to use va_list

S

shiva

i want to write a pgm which can take any number of integers(using
va_list,... operator).

but i am not able to find the end of integers, can any body help me
out.
shiva
 
M

Michael

Hi,

I am far from being an expert in C so please
correct me if am wrong, but
in the FAQ 15.8 states that there no way to do
this. So I guess you have to pass this information
as the first parameter.

regards,
michael
 
F

Flash Gordon

Michael said:
I am far from being an expert in C so please
correct me if am wrong, but
in the FAQ 15.8 states that there no way to do
this. So I guess you have to pass this information
as the first parameter.

You are correct that the C language does not provide any mechanism for
detecting the end of a list of arguments. So, for the OP to write a
function taking a list of integers without using a sentinel value, such
as 0 or MIN_INT to indicate the end of the list, the only option is to
pass the number of elements and it makes sense for this to be the first
parameter.

Please include enough context in your reply for people to see what you
are replying to. Usenet does not guarantee that people receive messages
in order and, even if they do, they might have read the message you are
replying to a few weeks before they read your reply if they happen to go
on holiday before seeing your reply. So without the context you reply
will often make absolutely no sense.
 
M

Michael Mair

Flash said:
You are correct that the C language does not provide any mechanism for
detecting the end of a list of arguments. So, for the OP to write a
function taking a list of integers without using a sentinel value, such
as 0 or MIN_INT to indicate the end of the list, the only option is to

nit: INT_MIN
 
M

Michael

Hi Flash,

Flash said:
Please include enough context in your reply for people to see what you
are replying to. Usenet does not guarantee that people receive messages
in order and, even if they do, they might have read the message you are
replying to a few weeks before they read your reply if they happen to go
on holiday before seeing your reply. So without the context you reply
will often make absolutely no sense.
thanks for the information, I'll remember this next time
and include enough of the old text to ensure the context.
Sorry for breaking this rule.

Regards,
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top