Skip to content

Instantly share code, notes, and snippets.

@frankie-yanfeng
Created January 10, 2020 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankie-yanfeng/00abf47fc349cd6abcf78447339c1acb to your computer and use it in GitHub Desktop.
Save frankie-yanfeng/00abf47fc349cd6abcf78447339c1acb to your computer and use it in GitHub Desktop.
Sentinel Example
#include <stdio.h>
#include <stdarg.h>
void printlist(int begin, ...)
{
va_list ap;
char *p;
va_start(ap, begin);
p = va_arg(ap, char *);
while (p != NULL) {
fputs(p, stdout);
putchar('\n');
p = va_arg(ap, char*);
}
va_end(ap);
}
int main(void)
{
printlist(0, "hello", "world", "foo", "bar",NULL);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment