Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdarg>
- #include <iostream>
- using namespace std;
- int total (int num_args, ...)
- {
- va_list ap;
- int total = 0;
- va_start(ap, num_args);
- for (int x =0; x < num_args; x++)
- total += va_arg(ap, int);
- va_end(ap);
- return total;
- }
- int main ()
- {
- cout << total(9, 1,2,3,4,5,6,7,8,9) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement