• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Passing too many parameters to a function?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing too many parameters to a function?


  • Subject: Re: Passing too many parameters to a function?
  • From: almisr <email@hidden>
  • Date: Thu, 24 Aug 2006 10:40:39 +0200

Last I knew, that was a part of the C language standard.


It is not. There is no guarantee that you can pass extra arguments safely.

yep except if u build an known array (each time)

	-> arg[0] = [type:value]
	-> arg[1] = [type:value]

func (int num,arg[])
	parsing args for num


It is not. There is no guarantee that you can pass extra arguments safely.

yep standard case

------------------------------------------------------------------------ --------------------------------------
#include <stdio.h>
#include <stdarg.h>


/* void simple_printf( char *fmt,mixed array); */
void simple_printf( char *fmt,...);

int main(int argc, const char * argv[])
{
simple_printf("\n%s %s%s\n\n","hello","world","!");
simple_printf("\n%s %s%s %s %s %s %i\n \n","hello","world","!","we","are","in",2006);
return 0;
}


void simple_printf(char *format,...)
{
va_list list;
char *explode;
char *print_char;
int print_int;

va_start(list,format);
/*explode format*/
for(explode = format;*explode;++explode)
{
/* searching % */
if(*explode != '%')
putc(*explode,stdout);
else {
/* ++next */
switch(*++explode)
{
case 's':
{
print_char = va_arg(list,char *);
printf("%s",print_char);
continue;
}
case 'i':
{
print_int = va_arg(list,int);
printf("%i",print_int);
continue;
}
/* add types */
default:putc(*explode,stdout);
}
}
va_end(list);
fflush(stdout);
}
}
------------------------------------------------------------------------ --------------------------------------


Best Regards, {Plum}
  _
 /o\
// \\ The ASCII
\\ // Ribbon Campaign
 \V/  Against HTML
 /A\  eMail!
// \\




_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Passing too many parameters to a function? (From: email@hidden (Peter Seebach))

  • Prev by Date: Re: Passing too many parameters to a function?
  • Next by Date: Re: Passing too many parameters to a function?
  • Previous by thread: Re: Passing too many parameters to a function?
  • Next by thread: Re: Passing too many parameters to a function?
  • Index(es):
    • Date
    • Thread