Advertisement
Shiny_

Untitled

Apr 4th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdarg.h>
  2. #include <stdio.h>
  3.  
  4. #define program(arguments) void main(void) {arguments;}
  5.  
  6. int add(int number, ...) {
  7.     int sum = 0;
  8.     va_list arguments;
  9.     va_start(arguments, number);
  10.    
  11.     for(int i = 0; i < number; i++) {
  12.         sum += va_arg(arguments, int);
  13.     }
  14.    
  15.     va_end(arguments);
  16.     return sum;
  17. }
  18.  
  19. program(
  20.     printf("%d", add(1, 2, 3))
  21. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement