%z is now recognized by printf.
[glibc.git] / manual / examples / add.c
blobe4b1bba365e9a3918072ee706be290aa9d4179b1
1 #include <stdarg.h>
2 #include <stdio.h>
4 int
5 add_em_up (int count,...)
7 va_list ap;
8 int i, sum;
10 va_start (ap, count); /* Initialize the argument list. */
12 sum = 0;
13 for (i = 0; i < count; i++)
14 sum += va_arg (ap, int); /* Get the next argument value. */
16 va_end (ap); /* Clean up. */
17 return sum;
20 int
21 main (void)
23 /* This call prints 16. */
24 printf ("%d\n", add_em_up (3, 5, 5, 6));
26 /* This call prints 55. */
27 printf ("%d\n", add_em_up (10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
29 return 0;