Why Can't we use va_list twice?
Can any explain me how it creates memory issue ?
Multiple traversals of the list, each bracketed by va_start() and va_end() are possible.
So yes, you can use a
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.
Why Can't we use same va_list twice?
Answer rephrased: You can use the same
If you mean why can't you use the same
va_list twice without resetting it with
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?
firstly procedure is :
va_list ap; va_start(fmt,ap); then you can extract the variable agruments one by one using the va_arg(ap,type)
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. :-)