Home > Article > Backend Development > In C language, what happens if a function is called before it is declared?
If we do not use some function prototypes, and the function body is declared in a certain part after the statement that calls the function. In this case, the compiler assumes that the default return type is integer. But if the function returns a value of another type, an error will be returned. This works fine if the return type is also an integer, it may sometimes generate some warnings.
#include<stdio.h> main() { printf("The returned value: %d</p><p>", function); } char function() { return 'T'; //return T as character }
[Error] conflicting types for 'function' [Note] previous implicit declaration of 'function' was here
Now if the return type is integer then it will work.
#include<stdio.h> main() { printf("The returned value: %d</p><p>", function()); } int function() { return 86; //return an integer value }
The returned value: 86
The above is the detailed content of In C language, what happens if a function is called before it is declared?. For more information, please follow other related articles on the PHP Chinese website!