4 Years
Discussion Span
Last Post by nitin1

Quoting from man stdarg:

Multiple traversals of the list, each bracketed by va_start() and va_end() are possible.

So yes, you can use a va_list twice.


You can use a va_list twice, provided it's properly disposed of with va_end() and re-initialized with va_start() or copied with va_copy(). What you can't do is assume that va_list represents a bidirectional read-only collection. It could easily be a generated array or list of arguments that are modified or destroyed after processing with va_arg.

Votes + Comments
nice one!!

Answer rephrased: You can use the same va_list twice.

If you mean why can't you use the same va_list twice without resetting it with va_end and va_start: How would that work? You have to rewind it somehow - otherwise how could it possibly know that you want to start from the beginning and not just read more arguments?

Votes + Comments
hehe :p


firstly procedure is :

va_list ap;
then you can extract the variable agruments one by one using the va_arg(ap,type)

. simple!

If, you want to use va_list again for the same variable arguments, then end it first. how ? using va_end(ap); . now what ? now again repeat my procedure which i have given above. that's set. thanks. :-)

Edited by nitin1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.