Skip to content

Instantly share code, notes, and snippets.

@serivires
Last active December 16, 2015 17:19
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 serivires/5469721 to your computer and use it in GitHub Desktop.
Save serivires/5469721 to your computer and use it in GitHub Desktop.
#include <stdarg.h>
int add(int, ...);
int main(void) {
printf("%d \n", add(3, 100, 200, 300));
system("pause");
return 0;
}
int add(int cnt, ...) {
int i, sum = 0;
va_list list;
va_start(list, cnt);
for (i = 0; i < cnt; i++) {
sum += va_arg(list, int);
}
va_end(list);
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment