1<html lang="en"> 2<head> 3<title>va_arg - Untitled</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Untitled"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Stdarg.html#Stdarg" title="Stdarg"> 9<link rel="prev" href="va_005fstart.html#va_005fstart" title="va_start"> 10<link rel="next" href="va_005fend.html#va_005fend" title="va_end"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<meta http-equiv="Content-Style-Type" content="text/css"> 13<style type="text/css"><!-- 14 pre.display { font-family:inherit } 15 pre.format { font-family:inherit } 16 pre.smalldisplay { font-family:inherit; font-size:smaller } 17 pre.smallformat { font-family:inherit; font-size:smaller } 18 pre.smallexample { font-size:smaller } 19 pre.smalllisp { font-size:smaller } 20 span.sc { font-variant:small-caps } 21 span.roman { font-family:serif; font-weight:normal; } 22 span.sansserif { font-family:sans-serif; font-weight:normal; } 23--></style> 24<link rel="stylesheet" type="text/css" href="../cs.css"> 25</head> 26<body> 27<div class="node"> 28<a name="va_arg"></a> 29<a name="va_005farg"></a> 30<p> 31Next: <a rel="next" accesskey="n" href="va_005fend.html#va_005fend">va_end</a>, 32Previous: <a rel="previous" accesskey="p" href="va_005fstart.html#va_005fstart">va_start</a>, 33Up: <a rel="up" accesskey="u" href="Stdarg.html#Stdarg">Stdarg</a> 34<hr> 35</div> 36 37<h4 class="subsection">13.1.2 Extract a value from argument list</h4> 38 39<p><a name="index-va_005farg-498"></a><strong>Synopsis</strong> 40<pre class="example"> #include <stdarg.h> 41 <var>type</var> va_arg(va_list <var>ap</var>, <var>type</var>); 42</pre> 43 <p><strong>Description</strong><br> 44<code>va_arg</code> returns the next unprocessed value from a variable 45argument list <var>ap</var> (which you must previously create with 46<var>va_start</var>). Specify the type for the value as the second parameter 47to the macro, <var>type</var>. 48 49 <p>You may pass a <code>va_list</code> object <var>ap</var> to a subfunction, and use 50<code>va_arg</code> from the subfunction rather than from the function 51actually declared with an ellipsis in the header; however, in that case 52you may <em>only</em> use <code>va_arg</code> from the subfunction. ANSI C does 53not permit extracting successive values from a single variable-argument 54list from different levels of the calling stack. 55 56 <p>There is no mechanism for testing whether there is actually a next 57argument available; you might instead pass an argument count (or some 58other data that implies an argument count) as one of the fixed arguments 59in your function call. 60 61 <p><strong>Returns</strong><br> 62<code>va_arg</code> returns the next argument, an object of type <var>type</var>. 63 64 <p><strong>Portability</strong><br> 65ANSI C requires <code>va_arg</code>. 66 67 </body></html> 68 69