fork download
  1. #include <stdio.h>
  2. #include <stdarg.h>
  3.  
  4. void vfunc(int count, va_list list, ...) {
  5. int it = 0,
  6. end = count;
  7. va_list args;
  8.  
  9. for (it = 0; it < end; it++) {
  10. int arg = va_arg(list, int);
  11.  
  12. fprintf(stderr,
  13. "LIST: %d\n", arg);
  14. }
  15.  
  16. va_start(args, list);
  17.  
  18. for (it = 0; it < end; it++){
  19. int arg = va_arg(args, int);
  20.  
  21. fprintf(stderr,
  22. "ARGS: %d\n", arg);
  23. }
  24.  
  25. va_end(args);
  26. }
  27.  
  28. void func(int count, ...) {
  29. va_list args;
  30.  
  31. va_start(args, count);
  32. vfunc(count, args, 4,5,6);
  33. va_end(args);
  34. }
  35.  
  36. int main(int argc, char **argv) {
  37. func(3, 1,2,3);
  38.  
  39. return 0;
  40. }
Success #stdin #stdout #stderr 0s 4512KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
LIST: 1
LIST: 2
LIST: 3
ARGS: 4
ARGS: 5
ARGS: 6