|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
void printk(int a, char *fmt, ...)
{
int i =0;
int Ret = 0;
char fomt[200];
char Fomtt[200];
int *tmp = &a;
tmp = tmp + 2;
for (i = 0; i < 200; i++)
{
fomt[i] = fmt[i];
if (fomt[i] == '\n')
{
i = 200;
Fomtt[0] = Ret;
}
if (fomt[i] == '%')
{
Ret++;
}
if ((fomt[i] == 'd') & (fomt[i-1] == '%'))
{
Fomtt[Ret] = 'd';
}
if ((fomt[i] == 's') & (fomt[i-1] == '%'))
{
Fomtt[Ret] = 's';
}
if ((fomt[i] == 'c') & (fomt[i-1] == '%'))
{
Fomtt[Ret] = 'c';
}
if ((fomt[i] == 'x') & (fomt[i-1] == '%'))
{
Fomtt[Ret] = 'x';
}
}
for (i = 0;i < Ret; i++)
{
if (Fomtt[i+1] == 's')
{
if (a == 1)
{
printf("ERROR:%s \n", *tmp);
}
if (a == 2)
{
printf("INFO:%s \n", *tmp);
}
}
if (Fomtt[i+1] == 'd')
{
if (a == 1)
{
printf("ERROR:%d \n", *tmp);
}
if (a == 2)
{
printf("INFO:%d \n", *tmp);
}
}
if (Fomtt[i+1] == 'x')
{
if (a == 1)
{
printf("ERROR:%x \n", *tmp);
}
if (a == 2)
{
printf("INFO:%x \n", *tmp);
}
}
if (Fomtt[i+1] == 'c')
{
if (a == 1)
{
printf("ERROR:%c \n", *tmp);
}
if (a == 2)
{
printf("INFO:%c \n", *tmp);
}
}
tmp++;
}
} |
|