#include <stdio.h>
#include <stdlib.h>
#include "fibolib.h"

int
main (int argc, char *argv[])
{
    int n;
    int res;
    char *p;
    int *series;

    if (argc >= 2) {
        n = strtol (argv[1], &p, 0);
        if ((p == argv[1]) || *p) {
            fprintf (stderr, "The \"%s\" string is not a number\n", argv[1]);
            return 1;
        }
    } else {
        printf ("Input number: ");
        scanf ("%d", &n);
    }

    res = fiboseries (&series, n);
    if (res <= 0) {
        fprintf (stderr, "fiboseries() failed for %d with code %d\n", n, res);
        return 1;
    }

    /* Incorrect use of the function without prototype!!! */
    fiboprint (series, n);

    printf ("fibocalls=%d\n", fibocalls);

    return 0;
}