. Advertisement .
..3..
. Advertisement .
..4..
Here is the program I run:
#include <stdio.h>
int main(int argc, const char * argv[])
{
int input;
printf("Please give me a number : ");
scanf("%d", &input);
getchar();
printf("The fibonacci number of %d is : %d", input, Fibonacci(input)); //!!!
}/* main */
int Fibonacci(int number)
{
if(number<=1){
return number;
}else{
int F = 0;
int VV = 0;
int V = 1;
for (int I=2; I<=getal; I++) {
F = VV+V;
VV = V;
V = F;
}
return F;
}
}/*Fibonacci*/
After I run, it returns an error:
warning : Implicit declaration of function 'Fibonacci' is invalid in C99
Does anyone have any suggestions for the problem below: implicit declaration of function is invalid in c99 in the c – How to correct it?
The cause:
You get the warning message because you don’t declare the function before you call it.
Solution:
You can declare the function by some ways:
int Fibonacci(int number);
In a file
.h
(such asmyfunctions.h
) and#include "myfunctions.h"
in C code.int Fibonacci(int number){..}
Before you use
main()
This is the combination the two elements. Before you
main()
function, you should type the prototype function in the C file.I have an additional note for you: The function
int Fibonacci(int number)
must be used only in the file in which it is implemented. It should be declaredstatic
in order not to appear in other translation unit except that unit.Before it can use the function, the compiler needs to know about it.
Before you call the function, declare it