Mercurial > hg > CbC > old > device
view test/tstdarg.c @ 423:8b9136a06f56
bitfield continue...
author | kono |
---|---|
date | Fri, 29 Oct 2004 14:20:19 +0900 |
parents | 1ec915dcd2d1 |
children | 0c256ea2a97e |
line wrap: on
line source
#include <stdio.h> #include <stdarg.h> int var_args(char *numtypes, ...) { int t; int i; float f; double d; long long l; char *s; va_list ap; va_start(ap,numtypes); while((t= *numtypes++)) { if (t=='i') { i = va_arg(ap,int); printf("int arg: %d\n",i); #if 0 } else if (t=='f') { f = va_arg(ap,float); printf("float arg: %g\n",f); #endif } else if (t=='d') { d = va_arg(ap,double); printf("double arg: %g\n",d); } else if (t=='l') { l = va_arg(ap,long long); printf("long long arg: %lld\n",l); } else if (t=='s') { s = va_arg(ap,char *); printf("char *arg: %s\n",s); } else { s = va_arg(ap,char *); printf("arg: error\n"); } } } main() { var_args("iiiiii",1,2,3,4,5,6); var_args("llllll",(long long)1,(long long)2,(long long)3,(long long)4,(long long)5,(long long)6); #if 0 var_args("ffffff",(float)1,(float)2,(float)3,(float)4,(float)5,(float)6); #endif var_args("dddddd",(double)1,(double)2,(double)3,(double)4,(double)5,(double)6); var_args("ssssss","1","2","3","4","5","6"); return 0; }