mirror of
https://github.com/frida/tinycc
synced 2024-11-24 08:39:37 +03:00
b5f88b593a
A non declared function leads to a seriuos problems. And while gcc don't turn this warning on lets tcc do it. This warning can be turned off by -Wno-implicit-function-declaration option. And autor must explicitly do this if program must be compiled with this warning off.
25 lines
343 B
C
25 lines
343 B
C
#include <stdio.h>
|
|
#include <stdlib.h> // atoi()
|
|
|
|
int fib(n)
|
|
{
|
|
if (n <= 2)
|
|
return 1;
|
|
else
|
|
return fib(n-1) + fib(n-2);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int n;
|
|
if (argc < 2) {
|
|
printf("usage: fib n\n"
|
|
"Compute nth Fibonacci number\n");
|
|
return 1;
|
|
}
|
|
|
|
n = atoi(argv[1]);
|
|
printf("fib(%d) = %d\n", n, fib(n));
|
|
return 0;
|
|
}
|