Mercurial > hg > CbC > old > device
view test/tstdarg.c @ 739:0c7a6ae119ba
i64 continue... compiler compiled.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Nov 2010 22:22:46 +0900 |
parents | a4445cb1aa91 |
children | ebf5ae3f3863 |
line wrap: on
line source
#include <stdio.h> #include <stdarg.h> void 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("#0021:int arg: %d\n",i); #if 0 } else if (t=='f') { f = va_arg(ap,float); printf("#0025:float arg: %g\n",f); #endif } else if (t=='d') { d = va_arg(ap,double); printf("#0029:double arg: %g\n",d); } else if (t=='l') { l = va_arg(ap,long long); printf("#0032:long long arg: %lld\n",l); } else if (t=='s') { s = va_arg(ap,char *); printf("#0035:char *arg: %s\n",s); } else { s = va_arg(ap,char *); printf("#0038:arg: error\n"); } } } int 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; }