c - Xcode - Warning: Implicit declaration of function is invalid in C99 -
getting warning : implicit declaration of function 'fibonacci' invalid in c99. what's wrong?
#include <stdio.h> int main(int argc, const char * argv[]) { int input; printf("please give me number : "); scanf("%d", &input); getchar(); printf("the fibonacci number of %d : %d", input, fibonacci(input)); //!!! }/* main */ int fibonacci(int number) { if(number<=1){ return number; }else{ int f = 0; int vv = 0; int v = 1; (int i=2; i<=getal; i++) { f = vv+v; vv = v; v = f; } return f; } }/*fibonacci*/
the function has declared before it's getting called. done in various ways:
write down prototype in header
use if function shall callable several source files. write prototype
int fibonacci(int number);
down in.h
file (e.g.myfunctions.h
) ,#include "myfunctions.h"
in c code.move function before it's getting called first time
means, write down function
int fibonacci(int number){..}
beforemain()
functionexplicitly declare function before it's getting called first time
combination of above flavors: type prototype of function in c file beforemain()
function
as additional note: if function int fibonacci(int number)
shall used in file it's implemented, shall declared static
, it's visible in translation unit.
Comments
Post a Comment