#include<stdio.h>
#include<stdarg.h>
#include<assert.h>
void myprintf(const char *s1, ...)
{
assert(s1 != NULL);
va_list arg;
char c;
char ch;
char *str;
int temp;
va_start(arg, s1);
while (c=*s1++)
{
switch (c)
{
case'%' :
break;
case 'c':
ch = va_arg(arg,int);
putchar(ch);
break;
case 's':
str = va_arg(arg, char *);
fputs(str, stdout);
break;
case 'd':
temp = va_arg(arg, int);
printf("%d",temp);
break;
default:
putchar(c);
}
}
va_end(arg);
}
int main()
{
char *s = "aaaaaa";
char c = 'b';
int i = 1997;
myprintf("%s\n %c \n%d", s, c, i);
system("pause");
}