Server for Information Technologies

(095) 932-9212, 932-9213, 939-0783
E-mail: info@citforum.ru
(!) CIT Forum CD-ROM

VARARGS(3)
XENIX System V (21 1987)


varargs - ypae cco epeeo

	#include <varargs.h>
	
	function(va_alist)
	va_dcl
	va_list pvar;
	va_start(pvar);
	f=va_arg(pvar,type);
	va_end(pvar);


apoc oo ca oe popa, paoae co cca apyeo epeeo . y, oop oy epeaac cc apyeo pao (apep printf(3)) oope e coy varargs, caoc eepeoc, ocoy coco epea apyeo ao-ac.

Va_alist coyec aece apaepa y c epee co apyeo ooaae cco apyeo.

Va_dcl ec ocaee va_alist. oce eo e yo ca oy c ao.

Va_list o epeex, coyex epeeo pvar, oopa coyec pao co cco. oa ocaa o ee epe oa aa epeea.

Va_start(pvar) aec aa pvar a aao cca.

Va_arg (pvar,type) opaae cey apye cca, a oop yaae pvar. Type ec o oaeoo apyea. B cce oy cea apye pax o, o y oa a oepeoo apyea, a a o e opee o pe oe popa.

Va_end(pvar) aec aepe pao co cco.

B popae oe ecoo yaco pao c epee cco apyeo, aex ap va_start ... va_end.

PEP

	#include <stdio.h>
	#include <varargs.h>
	
	main()
	{
	   show(2,3.1,"buf",4.1,"end");
	   show(1,5.9,"hello");
	   show(4,6.2,"oops",5.3,"blah",5.1,"lovely",
	     2.3,"madrigal");
	}
	
	/* ep apye ee  "eoe"  yaae
	* a oeco ap apyeo, oope ocey
	*  a .  apa c epeee
	* c aae oo  yaae a cpo.
	*
	* aoe, o p epeae epeex c
	* aae oo o peopayc  
	* double, a epeee a char -   int.
	*/
	show(n,va_alist)
	int n;
	va_dcl
	{
	     va_list ap;
	     int i;
	     double f;
	     char *p;
	
	     va_start(ap);
	     for(i=0; i<n; i++) {
	          f = va_arg(ap,double);
	          p = va_arg(ap,char *);
	          printf("%4.1f %s\n",f,p);
	     }
	     va_end(ap);
	}

AEA
Baa y caa oa opee oeco apyeo, a a aea y e oe opee co epeax e apyeo o cey. Hapep, y excel epeaec yeo yaae aece paa oa cca apyeo. Printf opeee co apyeo, aapy opay cpoy.
Comments: info@citmgu.ru
Designed by Andrey Novikov
Copyright © CIT