Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!targon!andre From: andre@targon.UUCP (andre) Newsgroups: comp.lang.c Subject: Re: Grabbing "n" arguments in a function Message-ID: <1320@targon.UUCP> Date: 7 May 90 15:32:07 GMT References: <744@tmiuv0.uucp> <1990Apr22.010146.5001@utzoo.uucp> Reply-To: andre@targon.UUCP (andre) Organization: Nixdorf Computer BV., DO, P.O. Box 29,Vianen, The Netherlands Lines: 32 In article <1990Apr22.010146.5001@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: ]In article <744@tmiuv0.uucp> rick@tmiuv0.uucp writes: ]>What's the most portable way for a function to receive an arbitrary list of ]>arguments? ... ] ]The *only* maximally portable way to do this is to use the ]facility in ANSI C. Using , found in many current systems, [ things you should not do ] There is one more method though, accept an 'argv' like array as the argument to your function. as in, int number_args (a) char **a; { int n; for (n = 0 ; a[n] ; n++) ; return n; } And if you malloc and realloc the char * array, this size can change at runtime, while the varargs approach is fixed at compile time. -- The mail| AAA DDDD It's not the kill, but the thrill of the chase. demon...| AA AAvv vvDD DD Ketchup is a vegetable. hits!.@&| AAAAAAAvv vvDD DD {nixbur|nixtor}!adalen.via --more--| AAA AAAvvvDDDDDD Andre van Dalen, uunet!hp4nl!targon!andre