computing-systems-212 / Make & GDB Demo / files / bigfib.c
bigfib.c
Raw
#include <stdio.h>

extern char buf[];
extern size_t buf_size;
extern unsigned long long fib(unsigned long long);

int main(int argc, char **argv) {
    unsigned long long n, m;
    printf("enter a number: ");
    if (fgets(buf, buf_size-1, stdin) == NULL) {
        fprintf(stderr, "ERROR: could not read from the console\n");
        return 1;
    }
    if (sscanf(buf, "%llu", &n) != 1) {
        fprintf(stderr, "ERROR: console input is not an unsigned number\n");
        return 2;
    }
    m = fib(n);
    printf("Fibonacci number #%llu is %llu\n", n, m);
    return 0;
}