please dont rip this site

Language Ccpp Cref Examples Varlist.c

/ ************************************************************************
 *
 * Purpose: To show ... in action. This operator (?) allows us to pass
 *	    a variable number of parameters to a function, 'printf' 
 *	    uses ...
 * Author:  M.J. Leslie
 * Date:    09-Jul-94
 *
 ************************************************************************/

#include <stdio.h>
#include <stdarg.h>			/* va_list, va_arg, va_end	*/

int set(char *item, int, num, ...);

/************************************************************************/

main()
   {
   char *item="pear";

   (set (item,4, "apple", "pear", "banana", "grape") )
	? printf ("%s found\n", item) : printf("%s not found\n", item);

   }

/************************************************************************/

int set(char *item, int num, ...)
   {
   va_list ap;				/* define 'ap' It acts as a pointer 
					 * to the undefined variables.	*/
   int ok=0;
   int inc=0;
   va_start(ap, num);			/* seed 'ap'			*/

   do {
      if ( item == va_arg(ap, char *)) ok=1;
      } while ( ok==0 && ++inc < num);

   va_end(ap);				/* tidy up.			*/
   return (ok);
   }


file: /Techref/language/ccpp/cref/EXAMPLES/varlist.c, 1KB, , updated: 1997/4/21 09:52, local time: 2024/4/27 00:57,
TOP NEW HELP FIND: 
3.144.84.155:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://www.piclist.com/techref/language/ccpp/cref/EXAMPLES/varlist.c"> language ccpp cref EXAMPLES varlist</A>

Did you find what you needed?

  PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to www.piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .