Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdarg.h>
- int sum(int n, ...) {
- va_list va;
- va_start(va, n);
- int s = 0;
- for (int i = 0; i < n; i++) {
- s += va_arg(va, int);
- }
- va_end(va);
- return s;
- }
- int main() {
- printf("%d\n", sum(3, 1, 2, 3));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement