Skip to content

Instantly share code, notes, and snippets.

@tj
Created May 5, 2009 21:31
Show Gist options
  • Select an option

  • Save tj/107215 to your computer and use it in GitHub Desktop.

Select an option

Save tj/107215 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
void
print (char *format, ...) {
char c;
va_list args;
va_start(args, format);
while (c = *format++)
if (c == '%')
switch (*format++) {
case 's':
printf(va_arg(args, char *));
break;
}
else
putchar(c);
va_end(args);
}
int
main(int argc, char **argv) {
print("%s : %s\n", "foo", "bar");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment