Last active
December 16, 2015 17:19
-
-
Save serivires/5469721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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