URI: 
       02-prod.c - libzahl - big integer library
  HTML git clone git://git.suckless.org/libzahl
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       02-prod.c (496B)
       ---
            1 /* Calculates the product of $@ */
            2 
            3 #include <stdio.h>
            4 #include <stdlib.h>
            5 
            6 #include <zahl.h>
            7 
            8 int
            9 main(int argc, char *argv[])
           10 {
           11         z_t prod, factor;
           12         jmp_buf env;
           13         char *buf;
           14         int i;
           15 
           16         if (setjmp(env))
           17                 return zperror(argv[0]), 1;
           18 
           19         zsetup(env);
           20         zinit(prod);
           21         zinit(factor);
           22         zsetu(prod, 1);
           23 
           24         for (i = 1; i < argc; i++) {
           25                 zsets(factor, argv[i]);
           26                 zmul(prod, prod, factor);
           27         }
           28 
           29         printf("%s\n", buf = zstr(prod, NULL, 0));
           30         free(buf);
           31 
           32         zfree(factor);
           33         zfree(prod);
           34         zunsetup();
           35         return 0;
           36 }