Advertisement
pcwizz

don't do this

Oct 17th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <cstdarg>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int total (int num_args, ...)
  6. {
  7.     va_list ap;
  8.     int total = 0;
  9.     va_start(ap, num_args);
  10.     for (int x =0; x < num_args; x++)
  11.         total += va_arg(ap, int);
  12.     va_end(ap);
  13.     return total;
  14. }
  15.  
  16. int main ()
  17. {
  18.     cout << total(9, 1,2,3,4,5,6,7,8,9) << endl;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement