home *** CD-ROM | disk | FTP | other *** search
- #include <stdarg.h>
- #include <stdio.h>
-
- #include "pushpop.h"
-
- void showElems(int n, ...)
- {
- int i;
- va_list elems;
-
- for (i = 0, va_start(elems, n); i < n; i++)
- printf("%d ", va_arg(elems, int));
- va_end(elems);
- putchar('\n');
- }
-
- void showArray(int n, int a[])
- {
- int i;
-
- for (i = n - 1; i >= 0; i--)
- va_push(int, a[i]);
- showElems(n);
- va_pop(int, n);
- }
-
- int main()
- {
- int a[] = { 1, 8, -6, 3, 9, 4, 2, -1 };
-
- puts("Testing pushpop ...");
- showElems(3, 6, 7, 9);
- showArray(sizeof(a) / sizeof(int), a);
- puts("Returned successfully ... pushpop OK.");
-
- return (0);
- }