Originally Posted by
Desolation
Why do so much work ? It is possible to reproduce the exact same behaviour without that much crap.
This is what you are looking for, my friend.
That is why I was trying to use. I'm really confused now. Could you please explain this part. Why is fmt a pointer and how does the while loop know when to end? Thanks
Code:
while (*fmt)
switch(*fmt++) {
case 's': /* string */
s = va_arg(ap, char *);
printf("string %s\n", s);
break;
case 'd': /* int */
d = va_arg(ap, int);
printf("int %d\n", d);
break;
case 'c': /* char */
/* need a cast here since va_arg only
takes fully promoted types */
c = (char) va_arg(ap, int);
printf("char %c\n", c);
break;
}