请教下下面C程序的错误
代码段如下: gcc 编译报错:vprintf.c: In function ‘tprintf’: vprintf.c:20: error: expected ‘;’ before ‘{’ token错误很简单,少个分号, 问题是我觉得不应该有这个错误, 压根不知道 “;”该加在哪?
#include<stdio.h>
#include<stdarg.h>
#include<string.h>
void tprintf(const char*format,...)
{
va_list ap;
int i;
va_start(ap,format);
if(format==NULL)printf("Defined error!");
for(i=0;i<strlen(format);i++)
which(*(format+i))
{
case 'd':printf("%d\n",va_arg(ap,int));break;
case 'c':printf("%c\n",va_arg(ap,char));break;
case 's':printf("%s\n",va_arg(ap,char));break;
case 'f':printf("%f\n",va_arg(ap,float));break;
default:printf("%s\n",format);break;
}
va_end(ap);
}
int main()
{
char a[]="cds";
tprintf(a,'r',14,"zou");
printf("%c%d%s\n",'r',14,"zou");
return 0;
}