Re: Passing too many parameters to a function?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Last I knew, that was a part of the C language standard. 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 yep standard case /* void simple_printf( char *fmt,mixed array); */ void simple_printf( char *fmt,...); 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... It is not. There is no guarantee that you can pass extra arguments safely. It is not. There is no guarantee that you can pass extra arguments safely. ------------------------------------------------------------------------ -------------------------------------- #include <stdio.h> #include <stdarg.h> 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); } } ------------------------------------------------------------------------ -------------------------------------- This email sent to site_archiver@lists.apple.com
participants (1)
-
almisr